commit 65878aa07452b45c3f17c3ab15508400edd46476
parent e0f9f9929d80d2c21ae1996b437d9209d498956b
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Wed, 18 Sep 2024 07:56:39 +0200
Some shellcheck
Diffstat:
8 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/configure.sh b/configure.sh
@@ -5,7 +5,7 @@ greparch() {
}
grepsan() {
- $CC -fsanitize=$1 -dM -E -x c - </dev/null 2>/dev/null | grep "SANITIZE"
+ $CC -fsanitize="$1" -dM -E -x c - </dev/null 2>/dev/null | grep "SANITIZE"
}
detectthreads() {
diff --git a/test/test.sh b/test/test.sh
@@ -8,19 +8,19 @@ TESTERR="test/last.err"
CUBEOBJ="debugcube.o"
for t in test/*; do
- if [ -n "$re" ] && [ -z "$(echo "$t" | grep "$re")" ]; then
+ if [ -n "$re" ] && !(echo "$t" | grep -q "$re"); then
continue
fi
# Verify if $t is a directory and if its name starts with three digits
- if [ -d "$t" ] && echo "$(basename "$t")" | grep -Eq '^[0-9]{3}'; then
- $CC -o $TESTBIN $t/*.c $CUBEOBJ || exit 1
- for cin in $t/*.in; do
+ if [ -d "$t" ] && basename "$t" | grep -Eq '^[0-9]{3}'; then
+ $CC -o $TESTBIN "$t"/*.c $CUBEOBJ || exit 1
+ for cin in "$t"/*.in; do
c=$(echo "$cin" | sed 's/\.in//')
- cout=$c.out
- printf "$c: "
+ cout="$c.out"
+ printf "%s: " "$c"
$TESTBIN < "$cin" > $TESTOUT 2> $TESTERR
- if diff $cout $TESTOUT; then
+ if diff "$cout" "$TESTOUT"; then
printf "OK\n"
else
printf "Test failed! stderr:\n"
diff --git a/tools/run_tool.sh b/tools/run_tool.sh
@@ -11,14 +11,14 @@ BIN="tools/run"
d="$(date +'%Y-%m-%d-%H-%M-%S')"
for t in tools/*; do
- if [ ! -d "$t" ] || [ -z "$(echo "$t" | grep "$TOOL")" ]; then
+ if [ ! -d "$t" ] || ! (echo "$t" | grep -q "$TOOL"); then
continue
fi
toolname="$(basename "$t" .c)"
- $CC -o $BIN $t/*.c $CUBEOBJ || exit 1;
+ $CC -o $BIN "$t"/*.c "$CUBEOBJ" || exit 1;
$BIN | tee "tools/results/$toolname-$d.txt" "tools/results/last.out"
break
done
# $BIN is kept so it can be run manually for profiling
-rm -rf $CUBEOBJ
+rm -rf "$CUBEOBJ"
diff --git a/utils/genmovecode.sh b/utils/genmovecode.sh
@@ -4,7 +4,7 @@ cc -DDEBUG h48_to_lst.c ../src/nissy.c -o h48_to_lst
gen() {
for f in cubes/move_??_*.txt; do
- move="$(echo $f | sed 's/.*_// ; s/\.txt//')"
+ move="$(echo "$f" | sed 's/.*_// ; s/\.txt//')"
printf '#define _move_cube_%s fastcube( \\\n ' "$move"
./h48_to_lst <"$f"
printf ')\n'
diff --git a/utils/genmoveswitch.sh b/utils/genmoveswitch.sh
@@ -2,7 +2,7 @@
printf '\tswitch (m) {\n'
for f in cubes/move_??_*.txt; do
- t="$(echo $f | sed 's/.*_// ; s/\.txt//')"
+ t="$(echo "$f" | sed 's/.*_// ; s/\.txt//')"
printf '\tcase %s:\n\t\treturn _move(%s, c);\n' "$t" "$t"
done
printf '\t}\n'
diff --git a/utils/gentranscode.sh b/utils/gentranscode.sh
@@ -10,7 +10,7 @@ sedsrc() { sed '3s/$/ };/ ; 3q'; }
gen() {
for f in cubes/transform_??_???.txt; do
- trans="$(echo $f | sed 's/.*_// ; s/\.txt//')"
+ trans="$(echo "$f" | sed 's/.*_// ; s/\.txt//')"
printf '#define _trans_cube_%s fastcube( \\\n ' "$trans"
./h48_to_lst <"$f"
printf ')\n'
diff --git a/utils/gentransswitch.sh b/utils/gentransswitch.sh
@@ -2,8 +2,8 @@
printf '\tswitch (t) {\n'
for f in cubes/transform_??_???.txt; do
- t="$(echo $f | sed 's/.*_// ; s/\.txt//')"
- mirror_or_rotation="$(echo $t | grep m)"
+ t="$(echo "$f" | sed 's/.*_// ; s/\.txt//')"
+ mirror_or_rotation="$(echo "$t" | grep m)"
if [ -z "$mirror_or_rotation" ]; then
m="rotation"
else
diff --git a/utils/gentranstests.sh b/utils/gentranstests.sh
@@ -8,9 +8,9 @@ i=100
while read -r line; do
[ -z "$line" ] && continue
- trans_piece="$(echo $line | awk '{print $1}' | tr -d 'rm')"
- move1="$(echo $line | awk '{print $2}')"
- move2="$(echo $line | awk '{print $3}')"
+ trans_piece="$(echo "$line" | awk '{print $1}' | tr -d 'rm')"
+ move1="$(echo "$line" | awk '{print $2}')"
+ move2="$(echo "$line" | awk '{print $3}')"
rotation="rotation $trans_piece"
@@ -23,7 +23,7 @@ while read -r line; do
i=$((i+1))
mirrored="mirrored $trans_piece"
- move2m="$(echo ${move2} | tr 'LR' 'RL')3"
+ move2m="$(echo "${move2}" | tr 'LR' 'RL')3"
file1="$(ls cubes | grep "move_.*_${move1}.txt")"
file2="$(ls cubes | grep "move_.*_${move2m}.txt")"