Merge pull request #1996 from xexyl/bmeyer2000-try

Deal with shellcheck warnings in 2000/bmeyer
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-01-21 15:43:16 -08:00
commit 43c5132cdb
12 files changed
+161 -14

No files matched your search

+5
View File
@@ -33,5 +33,10 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c: "
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2094 (info): Make sure not to read and write the same file in the same pipeline.
#
# shellcheck disable=SC2094
./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c
echo "Now explain any differences." 1>&2
+6
View File
@@ -33,5 +33,11 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c: "
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2094 (info): Make sure not to read and write the same file in the same pipeline.
#
# shellcheck disable=SC2094
./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c
echo "Now explain any differences." 1>&2
+16
View File
@@ -32,6 +32,14 @@ echo "Why do they differ in the format from the above command? Finally how can y
echo "get the more likely desired behaviour?" 1>&2
echo 1>&2
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we deliberately have \\n to show that there will be a newline printed
# WITH printf(1). Thus this does show correct output.
#
# shellcheck disable=SC2028
echo "$ ./dale \$(printf "the following files exist in this directory:\\n%s\\n" *)"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
@@ -40,6 +48,14 @@ echo 1>&2
./dale $(printf "the following files exist in this directory:\n%s\n" *)
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we deliberately have \\n to show that there will be a newline printed
# WITH printf(1). Thus this does show correct output.
#
# shellcheck disable=SC2028
echo "$ ./dale \"\$(printf \"the following files exist in this directory:\\n%s\\n\" *)\""
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
+1 -3
View File
@@ -12,9 +12,7 @@ fi
# let user change the sleep duration if they wish
#
if [[ -z "$SLEEP" ]]; then
SLEEP=1000
fi
[[ -z "$SLEEP" ]] && SLEEP=1000
# let user change the number if they wish to
#
+1 -1
View File
@@ -26,7 +26,7 @@ else
ARG="$2"
fi
make CC="$CC" SLEEP="$SLEEP" all >/dev/null || exit 1
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
+14
View File
@@ -26,6 +26,14 @@ ldb_file()
ldb_ioccc()
{
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we deliberately have \\n to show that there will be a newline printed
# WITH printf(1). Thus this does show correct output.
#
# shellcheck disable=SC2028
echo "$ printf \"The International Obfuscated C Code Contest\\nBest One-liner\\nby Laurion Burchall\" | ./ldb"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
@@ -33,6 +41,12 @@ ldb_ioccc()
echo 1>&2
}
# This warning from ShellCheck is irrelevant as we only use 'i' as an iterator
# to do the commands a number of times:
#
# SC2034 (warning): i appears unused. Verify use (or export if used externally).
#
# shellcheck disable=SC2034
for i in $(seq 1 5); do
ldb_file /etc/passwd
ldb_ioccc
+8 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
#
# try.alt.sh - demonstrate IOCCC winner 1995/garry alt code
#
@@ -15,6 +15,13 @@ make CC="$CC" alt >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want them to be expanded. This does show correct output.
#
# shellcheck disable=SC2028
echo "$ EXAMPLEON=\"\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2
EXAMPLEON="\33\133\61\73\67\155"
EXAMPLEOFF="\33\133\155"
+9 -3
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1995/garry
#
@@ -15,8 +15,14 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ EXAMPLEON=\"\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want them to be expanded. This does show correct output.
#
# shellcheck disable=SC2028
echo "$ EXAMPLEON=\"\\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2
EXAMPLEON="\33\133\61\73\67\155"
EXAMPLEOFF="\33\133\155"
DOLLAR="$"
+1 -1
View File
@@ -15,7 +15,7 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
while [[ 1 ]]; do
while :; do
read -r -n 1 -p "Press any key to run ./df or 'q' to quit: "
echo 1>&2
if [[ "$REPLY" = "q" || "$REPLY" = "Q" ]]; then
+58 -1
View File
@@ -17,9 +17,26 @@ clear
read -r -n 1 -p "Press any key to run: echo '((\a(\b(\c(d)))) e)' | ./fanf: "
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want to expand escape sequences. Thus this does show correct
# output.
#
# shellcheck disable=SC2028
echo '((\a(\b(\c(d)))) e)' | ./fanf
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want to expand escape sequences. Thus this does show correct
# output.
#
# shellcheck disable=SC2028
echo "$ echo '
(\f\g\x
(
@@ -28,6 +45,15 @@ echo "$ echo '
)'|./fanf" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want to expand escape sequences. Thus this does show correct
# output.
#
# shellcheck disable=SC2028
echo '
(\f\g\x
(
@@ -36,13 +62,36 @@ echo '
)'|./fanf
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want to expand escape sequences. Thus this does show correct
# output.
#
# shellcheck disable=SC2028
echo "$ echo '(\f(\f\g\x( (f((\a(g(b))) e)) (g x) ) K K z))' | ./fanf" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want to expand escape sequences. Thus this does show correct
# output.
#
# shellcheck disable=SC2028
echo '(\f(\f\g\x( (f((\a(g(b))) e)) (g x) ) K K z))' | ./fanf
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want to expand escape sequences. Thus this does show correct
# output.
#
# shellcheck disable=SC2028
echo "$ echo '
(Y\f\n
((= n 0)
@@ -53,6 +102,14 @@ echo "$ echo '
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
# This warning from ShellCheck is incorrect:
#
# SC2028 (info): echo may not expand escape sequences. Use printf.
#
# because we don't want to expand escape sequences. Thus this does show correct
# output.
#
# shellcheck disable=SC2028
echo '(Y\f\n
((= n 0)
1
+13 -4
View File
@@ -19,13 +19,22 @@ clear
# be determined: we just use a default value.
#
# try getting the columns the simple way first: tput cols
COLUMNS="$(tput cols)"
# ^--^ SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
COLUMNS="$(tputs cols)"
# In this case we might be able to get away with resolving this ShellCheck
# warning:
#
# SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
#
# but we want to assign the value to COLUMNS and at the same time make sure tput
# worked. Thus we disable this warning.
#
# shellcheck disable=SC2181
if [[ "$?" -ne 0 ]]; then
# if tput failed for any reason try stty(1) with awk(1):
# Disable this warning of shellcheck as it's wrong: awk needs single quotes.
# ^-----------^ SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
#
# SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
#
# shellcheck disable=SC2016
COLUMNS="$(stty size|awk '{print $NF}')"
@@ -74,7 +83,7 @@ echo 1>&2
./glicbawls "$COLUMNS" < lavabus.pgm > lavabus.glic
echo 1>&2
read -r -n 1 -p "Press any key to run: ./glicbawls -2 "$COLUMNS" < lavabus.pgm > lavabus.glic2: "
read -r -n 1 -p "Press any key to run: ./glicbawls -2 $COLUMNS < lavabus.pgm > lavabus.glic2: "
echo 1>&2
./glicbawls -2 "$COLUMNS" < lavabus.pgm > lavabus.glic2
echo 1>&2
+29
View File
@@ -22,6 +22,14 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0.001 $(./dmy2jd 7.8 1 1610): "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
#
# shellcheck disable=SC2046
./rince 0.001 $(./dmy2jd 7.8 1 1610)
echo 1>&2
@@ -42,15 +50,36 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 7.8 1 1610): "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
#
# shellcheck disable=SC2046
./rince 0 $(./dmy2jd 7.8 1 1610)
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 8.8 1 1610): "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
#
# shellcheck disable=SC2046
./rince 0 $(./dmy2jd 8.8 1 1610)
echo 1>&2
read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 10.8 1 1610): "
echo 1>&2
# ShellCheck is incorrect about:
#
# SC2046 (warning): Quote this to prevent word splitting.
#
# because we actually want word splitting.
#
# shellcheck disable=SC2046
./rince 0 $(./dmy2jd 10.8 1 1610)
echo 1>&2