]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
scripts/config: properly report and set string options
authorYann E. MORIN <yann.morin.1998@free.fr>
Mon, 9 Apr 2012 12:49:10 +0000 (14:49 +0200)
committerMichal Marek <mmarek@suse.cz>
Tue, 15 May 2012 22:13:11 +0000 (00:13 +0200)
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>
scripts/config

index a7c7c4b8e957311196f9b2eabef414ceaa144555..ed6653ef9702aa5320756537bb942e8a35123cb4 100755 (executable)
@@ -107,7 +107,8 @@ while [ "$1" != "" ] ; do
                ;;
 
        --set-str)
-               set_var "CONFIG_$ARG" "CONFIG_$ARG=\"$1\""
+               # sed swallows one level of escaping, so we need double-escaping
+               set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\""
                shift
                ;;
 
@@ -124,9 +125,11 @@ while [ "$1" != "" ] ; do
                        if [ $? != 0 ] ; then
                                echo undef
                        else
-                               V="${V/CONFIG_$ARG=/}"
-                               V="${V/\"/}"
-                               echo "$V"
+                               V="${V/#CONFIG_$ARG=/}"
+                               V="${V/#\"/}"
+                               V="${V/%\"/}"
+                               V="${V/\\\"/\"}"
+                               echo "${V}"
                        fi
                fi
                ;;