Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6686da8 authored by Yann E. MORIN's avatar Yann E. MORIN Committed by Michal Marek
Browse files

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: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
Acked-by: default avatarAndi Kleen <andi@firstfloor.org>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 9f420bf0
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -107,7 +107,8 @@ while [ "$1" != "" ] ; do
		;;
		;;


	--set-str)
	--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
		shift
		;;
		;;


@@ -124,9 +125,11 @@ while [ "$1" != "" ] ; do
			if [ $? != 0 ] ; then
			if [ $? != 0 ] ; then
				echo undef
				echo undef
			else
			else
				V="${V/CONFIG_$ARG=/}"
				V="${V/#CONFIG_$ARG=/}"
				V="${V/\"/}"
				V="${V/#\"/}"
				echo "$V"
				V="${V/%\"/}"
				V="${V/\\\"/\"}"
				echo "${V}"
			fi
			fi
		fi
		fi
		;;
		;;