From: Tom Rini Date: Fri, 7 Mar 2014 17:27:52 -0500 Subject: [U-Boot] [U-Boot, V3] hush: fix some quoted variable expansion issues In-Reply-To: <1393737370-15705-1-git-send-email-swarren@wwwdotorg.org> References: <1393737370-15705-1-git-send-email-swarren@wwwdotorg.org> Message-ID: <20140307222752.GJ16805@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Sat, Mar 01, 2014 at 10:16:10PM -0700, Stephen Warren wrote: > 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: Russell King > Acked-by: Simon Glass > Signed-off-by: Stephen Warren Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: