Closed amtssp closed 7 years ago
You'll just need to escape the double quotes in the string, for example:
#!/bin/sh
. shini.sh
shini_write "write_test.ini" "SECTION1" "unquoted" "string"
shini_write "write_test.ini" "SECTION1" "quoted" "\"string\""
cat write_test.ini
echo ""
(Note the \"
in the example above.) Executing produces:
$ sh write_test.sh
[SECTION1]
quoted="string"
unquoted=string
Thank you for your support. I thought I had tried that as well - but obviously I did something wrong. It is working fine.
One minor issue - when you find the time. When I write to an ini file it always insert an empty line in the beginning. It is more cosmetic..
Yeah I just noticed that too... (the blank line). ;-)
I'll open a separate issue for it.
Sorry, I still have a problem here. If I have more than one quoted string shini will "unquote" previously quoted strings.
Code like this
SECTION_NAME=TEST
shini_write "shairportsync.cfg" "${SECTION_NAME}" "unquoted" "string"
shini_write "shairportsync.cfg" "${SECTION_NAME}" "quoted" "\"string\""
shini_write "shairportsync.cfg" "${SECTION_NAME}" "quoted2" "\"string2\""
Results in only the last quoted string to be quoted.
[TEST]
unquoted=string
quoted=string
quoted2="string2"
Hi I would like my shairportsync.cfg file to look like this: [SHAIRPORT-SYNC] SHAIRPORT="yes"
I have a piece of code looking like this:
which result in this shairportsync.cfg file: [SHAIRPORT-SYNC] SHAIRPORT=yes
I haven't figured out how to add "" around the value?