Skip to content

Commit 2a18911

Browse files
Kevinjilvmcj
authored andcommitted
Fix shellcheck errors
1 parent 67c882d commit 2a18911

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

etc/gen_all_secrets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ create_pw_file()
1111
fi
1212

1313
# shellcheck disable=SC2039
14-
[ -n "$QUIET" ] || echo -n "Running '$SCRIPT'... "
14+
[ -n "$QUIET" ] || echo "Running '$SCRIPT'... "
1515
touch "$FILE"
1616
chmod go= "$FILE"
1717
"./$SCRIPT" > "$FILE"

gitlab/integration.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ mount -o remount,exec,dev /builds
8282
section_end mount
8383

8484
section_start check_cgroup_v1 "Checking for cgroup v1 availability"
85-
grep cgroup$ /proc/filesystems
86-
if [ $? -eq 0 ]; then
85+
86+
if grep cgroup$ /proc/filesystems; then
8787
cgroupv1=1
8888
else
8989
echo "Skipping tests that rely on cgroup v1"

judge/runguard_test/runguard_test.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/bin/bash
2+
# Ignore unreachable code, as it is called by `make test`.
3+
# shellcheck disable=SC2317
24

3-
cd "$(dirname "${BASH_SOURCE}")"
5+
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
46

57
RUNGUARD=../runguard
68
LOG1="$(mktemp)"
79
LOG2="$(mktemp)"
10+
# shellcheck disable=SC2154
811
META=$(mktemp -p "$judgehost_tmpdir")
912

1013
fail() {
@@ -98,7 +101,7 @@ test_streamsize() {
98101
exec_check_fail sudo $RUNGUARD -u domjudge-run-0 -t 1 -s 123 yes DOMjudge
99102
expect_stdout "DOMjudge"
100103
limit=$((123*1024))
101-
actual=$(cat "$LOG1" | wc -c)
104+
actual=$(wc -c < "$LOG1")
102105
[ $limit -eq $actual ] || fail "stdout not limited to ${limit}B, but wrote ${actual}B"
103106
}
104107

@@ -107,7 +110,7 @@ test_streamsize_stderr() {
107110
expect_stderr "DOMjudge"
108111
# Allow 100 bytes extra, for the runguard time limit message.
109112
limit=$((42*1024 + 100))
110-
actual=$(cat "$LOG2" | wc -c)
113+
actual=$(wc -c < "$LOG2")
111114
[ $limit -gt $actual ] || fail "stdout not limited to ${limit}B, but wrote ${actual}B"
112115
}
113116

@@ -120,7 +123,7 @@ test_redir_stdout() {
120123
grep -q "foobar" "$stdout" || fail "did not find expected 'foobar' in redirect stdout"
121124

122125
# Verify that stdout is empty.
123-
actual=$(cat "$LOG1" | wc -c)
126+
actual=$(wc -c < "$LOG1")
124127
[ $actual -eq 0 ] || fail "stdout should be empty, but contains ${actual}B"
125128

126129
# This will fail because of the timeout.
@@ -129,13 +132,13 @@ test_redir_stdout() {
129132
expect_stderr "hard wall time"
130133

131134
# Verify that stdout is empty.
132-
actual=$(cat "$LOG1" | wc -c)
135+
actual=$(wc -c < "$LOG1")
133136
[ $actual -eq 0 ] || fail "stdout should be empty, but contains ${actual}B"
134137

135138
# Verify that redirected stdout has the right contents.
136139
grep -q "DOMjudge" "$stdout" || fail "did not find expected 'DOMjudge' in redirect stdout"
137140
limit=$((23*1024))
138-
actual=$(cat "$stdout" | wc -c)
141+
actual=$(wc -c < "$stdout")
139142
[ $limit -eq $actual ] || fail "redirected stdout not limited to ${limit}B, but wrote ${actual}B"
140143

141144
rm "$stdout"
@@ -156,14 +159,15 @@ test_redir_stderr() {
156159
# Verify that redirected stdout has the right contents.
157160
grep -q "DOMjudge" "$stderr" || fail "did not find expected 'DOMjudge' in redirect stderr"
158161
limit=$((11*1024))
159-
actual=$(cat "$stderr" | wc -c)
162+
actual=$(wc -c < "$stderr")
160163
[ $limit -eq $actual ] || fail "redirected stdout not limited to ${limit}B, but wrote ${actual}B"
161164

162165
rm "$stderr"
163166
}
164167

165168
test_rootdir_changedir() {
166169
# Prepare test directory.
170+
# shellcheck disable=SC2154
167171
almost_empty_dir="$judgehost_judgedir/runguard_tests/almost_empty"
168172
mkdir -p "$almost_empty_dir"/exists
169173
cp hello "$almost_empty_dir"/
@@ -243,6 +247,7 @@ test_meta() {
243247
exec_check_fail sudo $RUNGUARD -u domjudge-run-0 -M "$META" false
244248
expect_meta 'exitcode: 1'
245249

250+
# shellcheck disable=SC2024
246251
echo "DOMjudge" | sudo $RUNGUARD -u domjudge-run-0 -t 2 -M "$META" rev > "$LOG1" 2> "$LOG2"
247252
expect_meta 'wall-time: 0.0'
248253
expect_meta 'stdout-bytes: 9'

judge/version_check.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ touch version_check.out version_check.meta
6666
if [ -e "$WORKDIR/version_check-script" ]; then
6767
mv "$WORKDIR/version_check-script" "$WORKDIR/version_check-script-old"
6868
fi
69+
# shellcheck disable=SC2174
6970
mkdir -m 0777 -p "$WORKDIR/version_check-script"
7071
cp -a "$VERSION_CHECK_SCRIPT" "$PWD/version_check-script/"
7172

0 commit comments

Comments
 (0)