Skip to content
Snippets Groups Projects
Commit fe9ca3d3 authored by Stephen Warren's avatar Stephen Warren Committed by Tom Rini
Browse files

hush: fix some quoted variable expansion issues


The following shell command fails:

if test -z "$x"; then echo "zero"; else echo "non-zero"; fi

(assuming $x does not exist, it prints "non-zero" rather than "zero").

... since "$x" expands to nothing, and the argument is completely
dropped, causing too few to be passed to -z, causing cmd_test() to
error out early.

This is because when variable expansions are processed by make_string(),
the expanded results are concatenated back into a new string. However,
no quoting is applied when doing so, so any empty variables simply don't
generate any parameter when the combined string is parsed again.

Fix this by explicitly replacing quoting any argument that was originally
quoted when re-generating a string from the already-parsed argument list.

This also fixes loss of whitespace in commands such as:

setenv space " "
setenv var " 1${space}${space} 2 "
echo ">>${var}<<"

Reported-by: default avatarRussell King <linux@arm.linux.org.uk>
Acked-by: default avatarSimon Glass <sjg@chromium.org>
Signed-off-by: default avatarStephen Warren <swarren@wwwdotorg.org>
parent eebd1b58
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment