aboutsummaryrefslogtreecommitdiff
path: root/runtest
diff options
context:
space:
mode:
authorBen Elliston <bje@gnu.org>2016-04-17 20:20:08 +1000
committerBen Elliston <bje@gnu.org>2016-04-17 20:20:08 +1000
commitdb72659fda602e65fc329cd7a3b66ac1d9832e01 (patch)
treea57ff118b49f7ae8ebfedd4bbd2a9400aa3da2c8 /runtest
parent1fd529da0d4122da7dd5d24cb1823da1f9ccec38 (diff)
downloaddejagnu-db72659fda602e65fc329cd7a3b66ac1d9832e01.zip
dejagnu-db72659fda602e65fc329cd7a3b66ac1d9832e01.tar.gz
dejagnu-db72659fda602e65fc329cd7a3b66ac1d9832e01.tar.bz2
Reported by shellcheck.
* runtest: Use $((..)) not `expr ..` and defensively double quote shell variables.
Diffstat (limited to 'runtest')
-rwxr-xr-xruntest41
1 files changed, 23 insertions, 18 deletions
diff --git a/runtest b/runtest
index 15fbea2..103108d 100755
--- a/runtest
+++ b/runtest
@@ -25,7 +25,7 @@
# Get the execution path to this script and the current directory.
mypath=${0-.}
-if expr ${mypath} : '.*/.*' > /dev/null
+if expr "$mypath" : '.*/.*' > /dev/null
then
:
else
@@ -33,21 +33,21 @@ else
for dir in $PATH
do
test -z "$dir" && dir=.
- if test -x $dir/$mypath
+ if test -x "$dir/$mypath"
then
- mypath=$dir/$mypath
+ mypath="$dir/$mypath"
break
fi
done
IFS="$save_ifs"
fi
-execpath=`echo ${mypath} | sed -e 's@/[^/]*$@@'`
+execpath=$(echo "$mypath" | sed -e 's@/[^/]*$@@')
# Get the name by which runtest was invoked and extract the config
# triplet.
-runtest=`echo ${mypath} | sed -e 's@^.*/@@'`
-target=`echo $runtest | sed -e 's/-runtest$//'`
+runtest=$(echo "$mypath" | sed -e 's@^.*/@@')
+target=$(echo "$runtest" | sed -e 's/-runtest$//')
if [ "$target" != runtest ] ; then
target="--target ${target}"
else
@@ -94,7 +94,7 @@ for a in "$@" ; do
done
if expr $verbose \> 0 > /dev/null ; then
- echo Expect binary is $expectbin
+ echo Expect binary is "$expectbin"
fi
# Find runtest.exp. First we look in its installed location,
@@ -109,14 +109,19 @@ fi
#
# .. which is a very weak assumption
-for i in `echo ${execpath} | sed -e 's@/[^/]*$@/share/dejagnu@'` `echo ${execpath} | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@'` $execpath /usr/share/dejagnu /usr/local/share/dejagnu ; do
- if expr $verbose \> 1 > /dev/null ; then
- echo Looking for $i/runtest.exp.
+for i in \
+ $(echo "$execpath" | sed -e 's@/[^/]*$@/share/dejagnu@') \
+ $(echo "$execpath" | sed -e 's@/[^/]*/[^/]*$@/share/dejagnu@') \
+ $execpath \
+ /usr/share/dejagnu \
+ /usr/local/share/dejagnu ; do
+ if expr "$verbose" \> 1 > /dev/null ; then
+ echo Looking for "$i"/runtest.exp.
fi
- if [ -f $i/runtest.exp ] ; then
+ if [ -f "$i/runtest.exp" ] ; then
runpath=$i
- if expr $verbose \> 0 > /dev/null ; then
- echo Using $i/runtest.exp as main test driver
+ if expr "$verbose" \> 0 > /dev/null ; then
+ echo Using "$i"/runtest.exp as main test driver
fi
break
fi
@@ -126,8 +131,8 @@ done
if [ x"$DEJAGNULIBS" != x ] ; then
runpath=$DEJAGNULIBS
- if expr $verbose \> 0 > /dev/null ; then
- echo Using $DEJAGNULIBS/runtest.exp as main test driver
+ if expr "$verbose" \> 0 > /dev/null ; then
+ echo Using "$DEJAGNULIBS"/runtest.exp as main test driver
fi
fi
if [ x"$runpath" = x ] ; then
@@ -135,9 +140,9 @@ if [ x"$runpath" = x ] ; then
exit 1
fi
-if ! type $expectbin >/dev/null 2>/dev/null ; then
- echo "ERROR: unable to find expect on the PATH"
+if ! type "$expectbin" > /dev/null 2> /dev/null ; then
+ echo "ERROR: unable to find expect in the PATH"
exit 1
fi
-exec $expectbin $debug -- $runpath/runtest.exp $target ${1+"$@"}
+exec "$expectbin" "$debug" -- "$runpath/runtest.exp" "$target" ${1+"$@"}