Skip to content

Commit 287a635

Browse files
committed
refactor(update): polish probes and shellcheck directives
Consolidate the scattered shellcheck disables into one file header directive, replace the GNU-style cmp --quiet with the POSIX -s flag and note that no long form exists, and run both the cmp and grep probes through cmd_run. Restructure the guard with a positive condition and early return, a standalone colon resetting the failed probe's status, and the cya message on its own line, which drops the SC2015 disable while keeping the guard's quiet zero exit.
1 parent 6e7c7c4 commit 287a635

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

‎app/update‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# Updates README.adoc with current links to the public functions. By default
77
# does not update the file and works as a linter.
88
#
9-
# Uses local variables:
10-
# shellcheck disable=SC2039,SC3043
9+
# File not following, variable appears unused, and uses local variables:
10+
# shellcheck disable=SC1090,SC2034,SC2039,SC3043
1111
BSH="$(
1212
CDPATH='' cd -- "$(dirname -- "$0" 2>&1)" 2>&1 && pwd -P 2>&1
1313
)"/../lib/base.sh || {
@@ -24,19 +24,13 @@ BASE_APP_USAGE="$(
2424
printf >&2 %s\\n "$BASE_APP_USAGE"
2525
exit "$err"
2626
}
27-
28-
# Variable appears unused:
29-
# shellcheck disable=SC2034
3027
readonly \
3128
BASE_APP_USAGE \
3229
BASE_APP_VERSION=0.9.20260718 \
3330
BASE_MIN_VERSION=0.9.20260718 \
3431
BSH \
3532
TGT=README.adoc
3633
set -- "$@" --quiet
37-
38-
# File not following:
39-
# shellcheck disable=SC1090
4034
. "$BSH"
4135
readonly \
4236
BEG="$BASE_WIP"/beg \
@@ -85,23 +79,23 @@ parse() {
8579
readonly ACT
8680
}
8781

88-
# Compares the new README against the current one. Updates if needed.
82+
# Compares the new README against the current one. Updates if needed. cmp
83+
# takes the short -s flag, POSIX defines no long form.
8984
update() {
90-
cmp --quiet "$OUT" "$TGT" && cya "$TGT" is updated.
85+
cmd_run cmp -s "$OUT" "$TGT" && cya "$TGT" is updated.
9186
[ "$ACT" = false ] && die "$TGT" should be updated.
9287
iswritable "$TGT" || die
9388
cmd_run cp -f "$OUT" "$TGT"
9489
log "$TGT" has been updated.
9590
}
9691

97-
# Checks the environment. The colon resets the exit status, so cya after
98-
# the failed GNU grep probe leaves gracefully with 0.
92+
# Checks the environment. The colon resets the failed GNU grep probe's
93+
# status, so cya leaves gracefully with 0.
9994
validate() {
10095
isreadable "$BSH" "$TGT" || die
101-
cmd_run -q grep --help || {
102-
:
103-
cya GNU grep is required.
104-
}
96+
cmd_run grep --help && return
97+
:
98+
cya GNU grep is required.
10599
}
106100

107101
# Entry point.

0 commit comments

Comments
 (0)