Skip to content

Commit

Permalink
scripts/config: properly report and set string options
Browse files Browse the repository at this point in the history
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" <[email protected]>
Acked-by: Andi Kleen <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
yann-morin-1998 authored and michal42 committed May 15, 2012
1 parent 9f420bf commit d6686da
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/config
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;

Expand All @@ -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
;;
Expand Down

0 comments on commit d6686da

Please sign in to comment.