diff options
-rwxr-xr-x | bin/backup | 2 | ||||
-rwxr-xr-x | bin/bins | 4 | ||||
-rwxr-xr-x | bin/boop | 2 | ||||
-rwxr-xr-x | bin/cl | 26 | ||||
-rwxr-xr-x | bin/color | 1 | ||||
-rwxr-xr-x | bin/dice | 9 | ||||
-rwxr-xr-x | bin/grun | 2 | ||||
-rwxr-xr-x | bin/httpno | 8 | ||||
-rwxr-xr-x | bin/lines | 2 | ||||
-rwxr-xr-x | bin/menu | 8 | ||||
-rwxr-xr-x | bin/msg | 1 | ||||
-rwxr-xr-x | bin/yt | 3 | ||||
-rwxr-xr-x | etc/sh/cronjob.sh | 1 | ||||
-rw-r--r-- | etc/sh/rc | 1 | ||||
-rw-r--r-- | etc/sh/vcs-ps1.sh | 2 |
15 files changed, 53 insertions, 19 deletions
@@ -93,6 +93,8 @@ ARCHIVE_TAG="${1:-manual}" run() { set -x + # The contents of $VERBOSE_FLAGS doesn't involve user input: + # shellcheck disable=2086 borg create \ $VERBOSE_FLAGS \ --comment "$COMMENT" \ @@ -64,8 +64,10 @@ shift $((OPTIND- 1)) F="$XDG_CACHE_HOME/euandreh/bins" IFS=: +# Word-splitting is the goal: +# shellcheck disable=2086 if stest -rdq -n "$F" $PATH; then - trap "rm -f $F-tmp" EXIT + trap 'rm -f $F-tmp' EXIT stest -lxf $PATH | sort -u > "$F"-tmp mv "$F"-tmp "$F" fi @@ -77,7 +77,7 @@ else N=1 fi -CMD="$@" +CMD="$*" msg -"$N" -bs -D "${MESSAGE:-$CMD}" exit "$STATUS" @@ -187,6 +187,7 @@ for f in "$@"; do INTERACTIVE=false escape_name "$f" >> "$SCRIPT" done +set -- MAIN="$(mkstemp)" if [ "$NO_RC" = false ] && [ -e "$LISP_CLI_RC" ]; then @@ -217,7 +218,7 @@ if [ -z "$IMPL" ]; then fi done if [ -z "$IMPL" ]; then - printf 'Could not find any implementation in $PATH.\n' >&2 + printf "Could not find any implementation in \$PATH.\n" >&2 exit 2 fi fi @@ -228,6 +229,7 @@ if [ "$SKIP_DEFAULT_IMAGE" = false ] && [ -z "$IMAGE" ] && IMAGE="$DEFAULT_IMAGE" fi + case "$IMPL" in abcl) exit 4 @@ -242,19 +244,19 @@ case "$IMPL" in exit 4 ;; clisp) - ARGS="-ansi -i $MAIN" + set -- -ansi -i "$MAIN" if [ -n "$IMAGE" ]; then - set -- -M "$IMAGE" + set -- "$@" -M "$IMAGE" fi if [ "$NO_RC" = true ]; then - ARGS="$ARGS -norc" + set -- "$@" -norc fi if [ "$VERBOSE" = false ]; then - ARGS="$ARGS -q -q" + set -- "$@" -q -q else set -x fi - exec clisp $ARGS "$@" + exec clisp "$@" ;; cmucl) exit 4 @@ -269,19 +271,21 @@ case "$IMPL" in exit 4 ;; sbcl) - ARGS="--load $MAIN" + set -- --load "$MAIN" if [ -n "$IMAGE" ]; then - set -- --core "$IMAGE" + # The '--core' "C runtime option" must appear before the + # other "Lisp options", such as '--load'. + set -- --core "$IMAGE" "$@" fi if [ "$NO_RC" = true ]; then - ARGS="$ARGS --no-sysinit --no-userinit" + set -- "$@" --no-sysinit --no-userinit fi if [ "$VERBOSE" = false ]; then - ARGS="--noinform $ARGS" + set -- "$@" --noinform else set -x fi - exec sbcl "$@" $ARGS + exec sbcl "$@" ;; *) printf 'Unsupported implementation: "%s".\n\n' "$IMPL" >&2 @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=2059 set -eu usage() { @@ -18,15 +18,21 @@ help() { SIZE the size of the dice (default: 6) + Roll a dice of SIZE. Caveat: rolling a dice more than once in + the same second will give you the same number. + + Examples: Roll a dice of size 6: $ dice + 3 Roll a D20: $ dice 20 + 15 EOF } @@ -63,4 +69,5 @@ shift $((OPTIND - 1)) SIZE="${1:-6}" -echo $(((RANDOM % SIZE) + 1)) +RAND="$(awk 'BEGIN { srand(); print int(rand()*32768) }' /dev/null)" +echo $(((RAND % SIZE) + 1)) @@ -91,4 +91,6 @@ else OUT="$(gpg -dq "$FILENAME" | "$@")" fi +# GPG recipients can't contain spaces: +# shellcheck disable=2086 echo "$OUT" | gpg -e ${RECIPIENTS_FLAG:--r eu@euandre.org} | sponge "$FILENAME" @@ -45,7 +45,8 @@ help() { } DATA() { - awk 'd == 1 { print; next } /^__DATA__$/ { d = 1 }' "$0" + awk 'd == 1 { print; next } /^__DATA__$/ { d = 1 }' "$0" | + head -n -1 # trim ShellCheck quote } @@ -88,6 +89,10 @@ fi exit + +# Make ShellCheck happy. See https://github.com/koalaman/shellcheck/issues/1201 +# shellcheck disable=1112 +echo " __DATA__ 100 Continue 101 Switching Protocols @@ -148,3 +153,4 @@ __DATA__ 509 Bandwidth Limit Exceeded 510 Not Extended 511 Network Authentication Required +" @@ -73,7 +73,7 @@ START="${1:-}" if [ -z "${2:-}" ]; then END=1 else - END=$(($2 - $START + 1)) + END=$(($2 - START + 1)) fi eval "$(assert-arg "$START" 'START')" @@ -76,7 +76,8 @@ eval "$(assert-arg "$ACTION" 'ACTION')" DATA() { - awk 'd == 1 { print; next } /^__DATA__$/ { d = 1 }' "$0" + awk 'd == 1 { print; next } /^__DATA__$/ { d = 1 }' "$0" | + head -n -1 # trim ShellCheck quote } show() { @@ -144,6 +145,10 @@ esac exit + +# Make ShellCheck happy. See https://github.com/koalaman/shellcheck/issues/1201 +# shellcheck disable=1112 +echo ' __DATA__ grinning face π smiling face with open mouth π @@ -1577,3 +1582,4 @@ Western Sahara πͺπ Yemen πΎπͺ Zambia πΏπ² Zimbabwe πΏπΌ +' @@ -68,7 +68,6 @@ MAIL=false DESKTOP=false BELL=false ACTION_DONE=false -SHOW_USAGE=false while getopts '01XsSmDbh' flag; do case "$flag" in 0) @@ -100,6 +100,9 @@ if [ -z "${FORCE:-}" ]; then EXTRA_OPTIONS="--download-archive $HOME/Downloads/yt-dl/seen.txt" fi +# The value of $EXTRA_OPTIONS doesn't depend on user input, and can't contain +# spaces, unless $HOME contains spaces: +# shellcheck disable=2086 youtube-dl \ --batch-file "$F" \ --format best \ diff --git a/etc/sh/cronjob.sh b/etc/sh/cronjob.sh index 1e11b50..05022e0 100755 --- a/etc/sh/cronjob.sh +++ b/etc/sh/cronjob.sh @@ -65,6 +65,7 @@ done shift $((OPTIND - 1)) +# shellcheck disable=1090 . ~/.usr/etc/sh/rc CMD="$*" with-email -s "$CMD" -- "$@" 1>>"$XDG_LOG_HOME"/euandreh/mcron.log 2>&1 @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=1090,1091 export ENV=~/.profile diff --git a/etc/sh/vcs-ps1.sh b/etc/sh/vcs-ps1.sh index b9a849a..7cc528d 100644 --- a/etc/sh/vcs-ps1.sh +++ b/etc/sh/vcs-ps1.sh @@ -128,7 +128,7 @@ shell_status_level() { } shell_status_jobs() { - JOBS="$(jobs | grep -v autojump | wc -l)" + JOBS="$(jobs | grep -c autojump)" if [ "$JOBS" != 0 ]; then color -c red "$JOBS" fi |