Skip to content

Commit

Permalink
lint: prefer $() instead of ``
Browse files Browse the repository at this point in the history
Latter is more concise but has several weaknesses,
including undefined behaviors.

Reference: https://www.shellcheck.net/wiki/SC2006
  • Loading branch information
slivingston committed Aug 28, 2024
1 parent bd1905c commit 24cdecc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CUDDVER=3.0.0
SPINVER=6.5.2

cd extern/src/cudd-$CUDDVER
./configure --prefix=`pwd`/../..
./configure --prefix="$(pwd)/../.."
make
make install

Expand Down
6 changes: 3 additions & 3 deletions get-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ then
fi

if hash sha256sum >/dev/null 2>&1; then
FILECHECKSUM=`sha256sum extern/cudd-$CUDDVER.tar.gz| sed 's/ .*//'`
FILECHECKSUM=$(sha256sum extern/cudd-$CUDDVER.tar.gz| sed 's/ .*//')
elif hash shasum >/dev/null 2>&1; then
FILECHECKSUM=`shasum -a 256 extern/cudd-$CUDDVER.tar.gz| sed 's/ .*//'`
FILECHECKSUM=$(shasum -a 256 extern/cudd-$CUDDVER.tar.gz| sed 's/ .*//')
else
echo "neither `sha256sum` nor `shasum` found in the PATH."
echo 'neither `sha256sum` nor `shasum` found in the PATH.'
rm extern/cudd-$CUDDVER.tar.gz
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions get-extra-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ then
fi

if hash sha256sum >/dev/null 2>&1; then
FILECHECKSUM=`sha256sum extern/spin${SPINVER}.tar.gz| sed 's/ .*//'`
FILECHECKSUM=$(sha256sum extern/spin${SPINVER}.tar.gz| sed 's/ .*//')
elif hash shasum >/dev/null 2>&1; then
FILECHECKSUM=`shasum -a 256 extern/spin${SPINVER}.tar.gz| sed 's/ .*//'`
FILECHECKSUM=$(shasum -a 256 extern/spin${SPINVER}.tar.gz| sed 's/ .*//')
else
echo "neither `sha256sum` nor `shasum` found in the PATH."
echo 'neither `sha256sum` nor `shasum` found in the PATH.'
rm extern/spin${SPINVER}.tar.gz
exit 1
fi
Expand Down
14 changes: 7 additions & 7 deletions tests/test-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if test -z $VERBOSE; then
fi


export PATH=`pwd`/${BUILD_ROOT}:$PATH
export PATH="$(pwd)/${BUILD_ROOT}:$PATH"

if test $VERBOSE -eq 1; then
echo '\nChecking for detection of flawed command-line usage...'
Expand Down Expand Up @@ -72,15 +72,15 @@ done
if test $VERBOSE -eq 1; then
echo '\nParsing version message from `gr1c -V`...'
fi
VERSION_LINE=`gr1c -V | head -1`
VERSION_LINE=$(gr1c -V | head -1)
echo $VERSION_LINE | grep dev0 > /dev/null 2>&1
if [ $? -ne 0 ]; then
VERSION=`echo ${VERSION_LINE} | cut -d ' ' -f2`
VERSION_SPLIT=`echo ${VERSION} | sed 's/\./ /g'`
VERSION=$(echo ${VERSION_LINE} | cut -d ' ' -f2)
VERSION_SPLIT=$(echo ${VERSION} | sed 's/\./ /g')
if test $VERBOSE -eq 1; then
echo 'Found version:' ${VERSION}
fi
if [ `echo ${VERSION_SPLIT} | wc -w` -ne 3 ]; then
if [ $(echo ${VERSION_SPLIT} | wc -w) -ne 3 ]; then
echo $PREFACE 'detected version does not have 3 component numbers'
echo
exit 1
Expand All @@ -102,7 +102,7 @@ fi
if test $VERBOSE -eq 1; then
echo '\nComparing `gr1c help` and `gr1c -h`...'
fi
TMPFILE=`$MKTEMP`
TMPFILE=$($MKTEMP)
gr1c help > $TMPFILE
if ! (gr1c -h | diff $TMPFILE -); then
echo $PREFACE 'Outputs of `gr1c help` and gr1c -h` do not match'
Expand All @@ -113,7 +113,7 @@ fi
if test $VERBOSE -eq 1; then
echo '\nComparing `gr1c --help` and `gr1c -h`...'
fi
TMPFILE=`$MKTEMP`
TMPFILE=$($MKTEMP)
gr1c --help > $TMPFILE
if ! (gr1c -h | diff $TMPFILE -); then
echo $PREFACE 'Outputs of `gr1c --help` and gr1c -h` do not match'
Expand Down
14 changes: 7 additions & 7 deletions tests/test-gr1c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ UNREALIZABLE_REFSPECS="trivial_un.spc"
if test $VERBOSE -eq 1; then
echo "\nChecking specifications that should be realizable..."
fi
for k in `echo $REFSPECS`; do
for k in $(echo $REFSPECS); do
if test $VERBOSE -eq 1; then
echo "\t gr1c -r $TESTDIR/specs/$k"
fi
Expand All @@ -40,7 +40,7 @@ done
if test $VERBOSE -eq 1; then
echo "\nChecking specifications that should be unrealizable..."
fi
for k in `echo $UNREALIZABLE_REFSPECS`; do
for k in $(echo $UNREALIZABLE_REFSPECS); do
if test $VERBOSE -eq 1; then
echo "\t gr1c -r $TESTDIR/specs/$k"
fi
Expand Down Expand Up @@ -70,7 +70,7 @@ REFSPECS="trivial_2var.spc free_counter.spc count_onestep.spc trivial_mustblock.
if test $VERBOSE -eq 1; then
echo "\nPerforming regression tests for vanilla GR(1) synthesis..."
fi
for k in `echo $REFSPECS`; do
for k in $(echo $REFSPECS); do
if test $VERBOSE -eq 1; then
echo "\tComparing gr1c -t txt $TESTDIR/specs/$k \n\t\tagainst $TESTDIR/expected_outputs/${k}.listdump.out"
fi
Expand Down Expand Up @@ -133,7 +133,7 @@ REFSPECS="reach_2var.spc reach_2var_mustblock.spc reach_free_counter.spc reach_f
if test $VERBOSE -eq 1; then
echo "\nPerforming regression tests for reachability games..."
fi
for k in `echo $REFSPECS`; do
for k in $(echo $REFSPECS); do
if test $VERBOSE -eq 1; then
echo "\tComparing gr1c-rg -t txt $TESTDIR/specs/$k \n\t\tagainst $TESTDIR/expected_outputs/${k}.listdump.out"
fi
Expand All @@ -152,7 +152,7 @@ REFSPECS="trivial_partwin gridworld_bool"
if test $VERBOSE -eq 1; then
echo "\nPerforming regression tests for interaction..."
fi
for k in `echo $REFSPECS`; do
for k in $(echo $REFSPECS); do
if test $VERBOSE -eq 1; then
echo "\tComparing gr1c -i $TESTDIR/specs/${k}.spc < $TESTDIR/interaction_scripts/${k}_IN.txt \n\t\tagainst $TESTDIR/interaction_scripts/${k}_OUT.txt"
fi
Expand All @@ -169,7 +169,7 @@ done
if test $VERBOSE -eq 1; then
echo "\nChecking detection of flawed specification files..."
fi
for k in `ls flawed_specs/*.spc`; do
for k in $(ls flawed_specs/*.spc); do
if test $VERBOSE -eq 1; then
echo "\t gr1c -s $k"
fi
Expand All @@ -186,7 +186,7 @@ done
if test $VERBOSE -eq 1; then
echo "\nChecking detection of flawed reachability game (rg) specification files..."
fi
for k in `ls flawed_reach_specs/*.spc`; do
for k in $(ls flawed_reach_specs/*.spc); do
if test $VERBOSE -eq 1; then
echo "\t gr1c-rg -s $k"
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/test-grpatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ REFSPECS="gridworld_2x20_1obs"
if test $VERBOSE -eq 1; then
echo "\nPerforming regression tests for patch_localfixpoint()..."
fi
for k in `echo $REFSPECS`; do
for k in $(echo $REFSPECS); do
if test $VERBOSE -eq 1; then
echo "\tComparing gr1c -t aut $TESTDIR/specs/patching/${k}.spc \n\t\tagainst $TESTDIR/expected_outputs/patching/${k}.spc.autdump.out"
fi
Expand Down
6 changes: 3 additions & 3 deletions tests/test-verification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if test $VERBOSE -eq 1; then
fi

REFSPECS="count_onestep.spc empty.spc free_counter.spc gridworld_bool.spc gridworld_env.spc trivial_2var.spc trivial_mustblock.spc"
for REFSPC in `echo $REFSPECS`; do
for REFSPC in $(echo $REFSPECS); do
if test $VERBOSE -eq 1; then
echo "\nConstructing strategy for ${TESTDIR}/specs/${REFSPC}"
echo "\tgr1c -t aut ${TESTDIR}/specs/${REFSPC} > ${REFSPC}.aut"
Expand All @@ -33,7 +33,7 @@ for REFSPC in `echo $REFSPECS`; do
echo "\nVerifying it using Spin..."
echo "\tgr1c-autman -i specs/${REFSPC} ${REFSPC}.aut -P -o ${REFSPC}.aut.pml"
fi
FORMULA=`$BUILD_ROOT/gr1c-autman -i specs/${REFSPC} ${REFSPC}.aut -P -o ${REFSPC}.aut.pml`
FORMULA=$($BUILD_ROOT/gr1c-autman -i specs/${REFSPC} ${REFSPC}.aut -P -o ${REFSPC}.aut.pml)
if test $VERBOSE -eq 1; then
echo "\tspin -f \"!(${FORMULA})\" >> ${REFSPC}.aut.pml"
fi
Expand All @@ -44,7 +44,7 @@ for REFSPC in `echo $REFSPECS`; do
fi
${SPINEXE} -a ${REFSPC}.aut.pml
cc -o pan pan.c
if test `./pan -a | grep errors| cut -d: -f2` -ne 0; then
if test $(./pan -a | grep errors| cut -d: -f2) -ne 0; then
echo $PREFACE "Strategy does not satisfy specification ${TESTDIR}/specs/${REFSPC}\n"
exit 1
fi
Expand Down

0 comments on commit 24cdecc

Please sign in to comment.