[master] 6e21a2e Fix shell expansion when mixed with regular strings

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jan 16 07:09:05 CET 2017


commit 6e21a2ee385aaf1e8210e4904cf99ff8bb7a0f43
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Jan 16 06:46:51 2017 +0100

    Fix shell expansion when mixed with regular strings
    
    I noticed that some shells like ye olde bash available on SmartOS don't
    treat the following construct as single a token:
    
        ${dir}/${file}
    
    The following expands a single token on the RHS even if the variable
    contains spaces:
    
        var=${dir}
    
    But a token involving a regular string too needs to be protected by
    double quotes:
    
        var="${dir}/${file}"
    
    Even when none of the variables contain blanks.
    
    Refs #2139

diff --git a/tools/vtest.sh b/tools/vtest.sh
index b39e819..fdef9eb 100755
--- a/tools/vtest.sh
+++ b/tools/vtest.sh
@@ -180,17 +180,17 @@ failedtests () (
 	cd "${SRCDIR}"
 
 	VERSION=`./configure --version | awk 'NR == 1 {print $NF}'`
-	LOGDIR=varnish-$VERSION/_build/sub/bin/varnishtest/tests
+	LOGDIR="varnish-$VERSION/_build/sub/bin/varnishtest/tests"
 	VTCDIR=bin/varnishtest/tests
 
-	grep -l ':test-result: FAIL' $LOGDIR/*.trs |
+	grep -l ':test-result: FAIL' "$LOGDIR/*.trs" |
 	while read trs
 	do
 		name=`basename $trs .trs`
-		vtc=${name}.vtc
-		log=${name}.log
-		rev=`git log -n 1 --pretty=format:%H ${VTCDIR}/${vtc}`
-		cp ${LOGDIR}/${log} ${REPORTDIR}/_${log}
+		vtc="${name}.vtc"
+		log="${name}.log"
+		rev=`git log -n 1 --pretty=format:%H "${VTCDIR}/${vtc}"`
+		cp "${LOGDIR}/${log}" "${REPORTDIR}/_${log}"
 		echo "VTCGITREV ${name} ${rev}"
 		echo "MANIFEST _${log}"
 	done



More information about the varnish-commit mailing list