__ini_value: new parameter --quote

This parameter ensures the value is surrounded by double quotes. As it
directly edits the value variable, the quoting will be added/removed
automaticly.
This commit is contained in:
matze 2021-03-20 15:39:38 +01:00
parent 19c701e95d
commit 0d4868dcd5
4 changed files with 16 additions and 1 deletions

View File

@ -57,6 +57,11 @@ BEGIN {
comment_signs[i++] = tmp
}
if(system("test -f " (_param "quote")) == 0) {
# quote it now that it only wins checks against quoted values
value = ("\"" value "\"")
}
found=0
curr_section=""
if(section == "")

View File

@ -11,6 +11,11 @@ BEGIN {
get_param_array("comment-sign", comment_signs)
comment_sign = comment_signs[0]
if(system("test -f " (_param "quote")) == 0) {
# quote it now that it only wins checks against quoted values
value = ("\"" value "\"")
}
base_spaces = spaces(indentation)
delimiter_spaces = spaces(delimiter_space)
delimiter_w_spaces = (delimiter_spaces delimiter delimiter_spaces)
@ -59,5 +64,5 @@ function v_print_commented() {
}
# print comment
function c_print() {
printf "%s%s%s%s%s", base_spaces, comment_sign, " ", comment, ORS
printf "%s%s %s%s", base_spaces, comment_sign, comment, ORS
}

View File

@ -79,6 +79,10 @@ normalize
configuration file. Even if a key-value pair is correct as-is, it will
correct the line to be pretty and perfect.
quote
Wrap double quotes (``"``) around the value. If the value is previously
unquoted, the file will be modified to quote the value.
MESSAGES
--------

View File

@ -1 +1,2 @@
normalize
quote