diff options
author | Yann E. MORIN <yann.morin.1998@free.fr> | 2012-04-09 08:49:10 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2012-05-15 18:13:11 -0400 |
commit | d6686da814c884e341d3bd8aa54947c91cb678be (patch) | |
tree | 795f9f0c4d164ae758b31e9998bc3ca78f94b3a4 /scripts/config | |
parent | 9f420bf0f4a74e404b73b42b7fc3c85c20c64ea7 (diff) |
scripts/config: properly report and set string options
Currently, scripts/config removes the leading double-quote from
string options, but leaves the trailing double-quote.
Also, double-quotes in a string are escaped, but scripts/config
does not unescape those when printing
Finally, scripts/config does not escape double-quotes when setting
string options.
Eg. the current behavior:
$ grep -E '^CONFIG_FOO=' .config
CONFIG_FOO="Bar \"Buz\" Meh"
$ ./scripts/config -s FOO
Bar \"Buz\" Meh"
$ ./scripts/config --set-str FOO 'Alpha "Bravo" Charlie'
$ grep -E '^CONFIG_FOO=' .config
CONFIG_FOO="Alpha "Bravo" Charlie"
Fix those three, giving this new behavior:
$ grep -E '^CONFIG_FOO=' .config
CONFIG_FOO="Bar \"Buz\" Meh"
$ ./scripts/config -s FOO
Bar "Buz" Meh
$ ./scripts/config --set-str FOO 'Alpha "Bravo" Charlie'
$ grep -E '^CONFIG_FOO=' .config
CONFIG_FOO="Alpha \"Bravo\" Charlie"
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Acked-by: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/config')
-rwxr-xr-x | scripts/config | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/config b/scripts/config index a7c7c4b8e957..ed6653ef9702 100755 --- a/scripts/config +++ b/scripts/config | |||
@@ -107,7 +107,8 @@ while [ "$1" != "" ] ; do | |||
107 | ;; | 107 | ;; |
108 | 108 | ||
109 | --set-str) | 109 | --set-str) |
110 | set_var "CONFIG_$ARG" "CONFIG_$ARG=\"$1\"" | 110 | # sed swallows one level of escaping, so we need double-escaping |
111 | set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\"" | ||
111 | shift | 112 | shift |
112 | ;; | 113 | ;; |
113 | 114 | ||
@@ -124,9 +125,11 @@ while [ "$1" != "" ] ; do | |||
124 | if [ $? != 0 ] ; then | 125 | if [ $? != 0 ] ; then |
125 | echo undef | 126 | echo undef |
126 | else | 127 | else |
127 | V="${V/CONFIG_$ARG=/}" | 128 | V="${V/#CONFIG_$ARG=/}" |
128 | V="${V/\"/}" | 129 | V="${V/#\"/}" |
129 | echo "$V" | 130 | V="${V/%\"/}" |
131 | V="${V/\\\"/\"}" | ||
132 | echo "${V}" | ||
130 | fi | 133 | fi |
131 | fi | 134 | fi |
132 | ;; | 135 | ;; |