Skip to content

Commit 376214a

Browse files
committed
fix shellcheck warnings in scripts
1 parent c5ad947 commit 376214a

25 files changed

+79
-183
lines changed

appveyor.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

macosx/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ if which -s pkgbuild; then
125125
--package-path . \
126126
"$OUTFILE"
127127
echo "Cleaning up..."
128-
rm -rf $PKGID
128+
rm -rf "$PKGID"
129129
else
130130
echo "Preprocessing package description..."
131131
INDIR=mosh-package.pmdoc.in

scripts/wrap-compiler-for-flag-check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ if out=$("$@" 2>&1); then
1818
else
1919
code=$?
2020
echo "$out"
21-
exit $code
21+
exit "$code"
2222
fi

src/tests/e2e-failure.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
. "$(dirname "$0")/e2e-test-subrs"
55
PATH=$PATH:.:$srcdir
66
# Top-level wrapper.
7-
if [ $# -eq 0 ]; then
7+
if [ "$#" -eq 0 ]; then
88
e2e-test "$0" baseline variant different
99
exit
1010
fi
1111

1212
# OK, we have arguments, we're one of the test hooks.
13-
if [ $# -ne 1 ]; then
13+
if [ "$#" -ne 1 ]; then
1414
fail "bad arguments %s\n" "$@"
1515
fi
1616

src/tests/e2e-success.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
. "$(dirname "$0")/e2e-test-subrs"
55
PATH=$PATH:.:$srcdir
66
# Top-level wrapper.
7-
if [ $# -eq 0 ]; then
7+
if [ "$#" -eq 0 ]; then
88
e2e-test "$0" baseline direct variant verify same
99
exit
1010
fi
1111

1212
# OK, we have arguments, we're one of the test hooks.
13-
if [ $# -ne 1 ]; then
13+
if [ "$#" -ne 1 ]; then
1414
fail "bad arguments %s\n" "$@"
1515
fi
1616

src/tests/e2e-test

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dump_logs()
2222
dir=$1
2323
shift
2424
testname=$(basename "$dir" .d)
25-
for logfile in $dir/*.tmux.log; do
25+
for logfile in "$dir"/*.tmux.log; do
2626
printf "travis_fold:start:%s-%s\n" "$testname" "$(basename "$logfile")"
2727
cat "$logfile"
2828
printf "travis_fold:end:%s-%s\n" "$testname" "$(basename "$logfile")"
@@ -60,7 +60,7 @@ test_exitstatus()
6060
ssh_localhost_check()
6161
{
6262
ssh localhost :
63-
if [ $? -ne 0 ]; then
63+
if [ "$?" -ne 0 ]; then
6464
error "ssh to localhost failed\n"
6565
return 1
6666
fi
@@ -93,7 +93,7 @@ if [ -z "$srcdir" ]; then
9393
export srcdir=$PWD
9494
else
9595
srcdir="$(cd "$srcdir" && pwd)"
96-
if [ $? -ne 0 ]; then
96+
if [ "$?" -ne 0 ]; then
9797
error "can't cd to srcdir: %s\n" "$srcdir"
9898
exit 99
9999
fi
@@ -113,7 +113,7 @@ case "$(basename "$0")" in
113113
;;
114114
esac
115115

116-
if [ $# -lt 2 ]; then
116+
if [ "$#" -lt 2 ]; then
117117
test_error "not enough args\n"
118118
fi
119119

@@ -144,10 +144,10 @@ mkdir "${test_dir}"
144144

145145
on_exit() {
146146
rv=$?
147-
if test $rv -ne 0; then
147+
if test "$rv" -ne 0; then
148148
dump_logs "$test_dir" $test_args
149149
fi
150-
exit $rv
150+
exit "$rv"
151151
}
152152
trap on_exit EXIT
153153

@@ -219,7 +219,7 @@ for run in $server_tests; do
219219
${tmux_stdin} tmux -f /dev/null -S "${tmux_socket}" -C new-session -x 80 -y 24 "${srcdir}/print-exitstatus ${client_wrapper} ${sut} ${server_wrapper} \"${PWD}/${test_dir}/${run}\" \"${PWD}/${test_script} ${run}\"" > "${test_dir}/${run}.tmux.log"
220220
rv=$?
221221
rm -f "${tmux_socket}" "${test_dir}/tmux-socket"
222-
if [ $rv -ne 0 ]; then
222+
if [ "$rv" -ne 0 ]; then
223223
test_error "tmux failure on test %s\n" "$run"
224224
fi
225225
# Check for mosh failures
@@ -282,7 +282,7 @@ for compare in $compare_tests; do
282282
desired=n
283283
badresult=different
284284
fi
285-
if [ $differ != $desired ]; then
285+
if [ "$differ" != "$desired" ]; then
286286
test_failure "Output is %s between tests %s and %s\n" "$badresult" "$test1" "$test2"
287287
fi
288288
done
@@ -291,7 +291,7 @@ done
291291
if [ -n "$post" ]; then
292292
"${test_script}" post
293293
status=$?
294-
if [ $status -ne 0 ]; then
295-
test_exitstatus $status "Post test failed with exitstatus %d\n" $status
294+
if [ "$status" -ne 0 ]; then
295+
test_exitstatus "$status" "Post test failed with exitstatus %d\n" "$status"
296296
fi
297297
fi

src/tests/e2e-test-server

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ wait_for_clients()
1717
expected=$1
1818
while true; do
1919
n=$(tmux list-clients -F . | wc -l)
20-
if [ $expected -eq 1 ]; then
21-
if [ $n -eq 1 ]; then
20+
if [ "$expected" -eq 1 ]; then
21+
if [ "$n" -eq 1 ]; then
2222
return
2323
fi
24-
elif [ $n -ne 1 ]; then
24+
elif [ "$n" -ne 1 ]; then
2525
return
2626
fi
2727
sleep 1
@@ -30,7 +30,7 @@ wait_for_clients()
3030

3131
export MOSH_SERVER_PID=$PPID
3232

33-
if [ $# -lt 2 ]; then
33+
if [ "$#" -lt 2 ]; then
3434
printf "not enough args\n" >&2
3535
exit 99
3636
fi
@@ -40,8 +40,8 @@ rm -f "$testname.capture" "$testname.exitstatus"
4040
trap ":" TERM HUP QUIT # If the session closes on us, let the test we're running drive.
4141
on_exit() {
4242
rv=$?
43-
echo $rv > "$testname.exitstatus"
44-
exit $rv
43+
echo "$rv" > "$testname.exitstatus"
44+
exit "$rv"
4545
}
4646
trap on_exit EXIT
4747
# check for tmux
@@ -55,22 +55,22 @@ eval "$@"
5555
testret=$?
5656
# Capture mosh-server runtime if possible.
5757
runtime=$(ps -o time= $PPID 2>/dev/null)
58-
if [ $? -ne 0 ]; then # Cygwin...
58+
if [ "$?" -ne 0 ]; then # Cygwin...
5959
runtime=-
6060
fi
6161
# Wait for tmux client screen to become up to date.
6262
sleep 1
6363
printf "@@@ server complete @@@" >&2
6464
wait_for_clients 1
6565
i=0
66-
while [ $i -lt 60 ]; do
66+
while [ "$i" -lt 60 ]; do
6767
if grep -q "@@@ server complete @@@" "$testname.tmux.log"; then
6868
break
6969
fi
7070
i=$((i+1))
7171
sleep 1
7272
done
73-
if [ $i -ge 60 ]; then
73+
if [ "$i" -ge 60 ]; then
7474
printf "wait for tmux client update failed, erroring test\n" >&2
7575
exit 99
7676
fi
@@ -86,7 +86,7 @@ fi
8686
# Dump runtime into tmux log.
8787
printf "@@@ runtime %s @@@\n" "$runtime"
8888
# return useful exitstatus from harnessed command
89-
if [ $testret -ne 0 ]; then
89+
if [ "$testret" -ne 0 ]; then
9090
exit 1
9191
fi
9292
exit 0

src/tests/e2e-test-subrs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sleepf()
2323

2424
seq_function()
2525
{
26-
if [ $# -lt 1 ] || [ $# -gt 3 ]; then
26+
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then
2727
echo "bad args" >&2
2828
fi
2929
first=$1
@@ -95,7 +95,7 @@ tmux_check()
9595
fi
9696
fi
9797
version=$(tmux -V)
98-
if [ $? != 0 ]; then
98+
if [ "$?" != 0 ]; then
9999
error "tmux unavailable\n"
100100
return 1
101101
fi
@@ -119,7 +119,7 @@ tmux_check()
119119
tmux_check_socket=$(mktemp -d /tmp/mosh-tmux-check.XXXXXXXX)
120120
tmux -f /dev/null -S "${tmux_check_socket}/s" -C new-session true
121121
rv=$?
122-
rm ${tmux_check_socket}/s
123-
rmdir ${tmux_check_socket}
124-
return $rv
122+
rm "${tmux_check_socket}/s"
123+
rmdir "${tmux_check_socket}"
124+
return "$rv"
125125
}

src/tests/emulation-80th-column.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
. "$(dirname "$0")/e2e-test-subrs"
1313
PATH=$PATH:.:$srcdir
1414
# Top-level wrapper.
15-
if [ $# -eq 0 ]; then
15+
if [ "$#" -eq 0 ]; then
1616
e2e-test "$0" baseline post
1717
exit
1818
fi
1919

2020
# OK, we have arguments, we're one of the test hooks.
21-
if [ $# -ne 1 ]; then
21+
if [ "$#" -ne 1 ]; then
2222
fail "bad arguments %s\n" "$@"
2323
fi
2424

0 commit comments

Comments
 (0)