Skip to content

Commit 85ebc88

Browse files
author
endolinbot
committed
chore(shellcheck): adopt die idiom for early termination in touched .sh files
Address kriskowal's CHANGES_REQUESTED review on #401: replace bare `|| exit` after `cd` with `|| die "<context>"` so early-termination sites emit a context line to stderr and exit non-zero, as with Perl's `die`. Each touched script defines its own helper near the top: die() { printf '%s\n' "$*" >&2; exit 1; } `printf` (not `echo -e`) avoids portability traps under /bin/sh. Sites upgraded across the .sh files this PR touched: - packages/nat/scripts/npm-audit-fix.sh: `cd nat`, `cd integration-test` - scripts/npm-audit-fix.sh: `cd ???` - scripts/posttypedoc.sh: `cd docs`, `cd api-docs` scripts/check-packages.sh's terminal `exit "$EXIT"` and scripts/ shellcheck.sh's `exit 0` skip-when-empty are intentional orderly exits, not the early-termination pattern the review objects to. Left as-is. The "throughout" scope is the .sh files this PR touched (the seven plus the new scripts/shellcheck.sh); broader cross-tree adoption is left to a separate dispatch if the maintainer wants it.
1 parent fe73a47 commit 85ebc88

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

packages/nat/scripts/npm-audit-fix.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
2+
die() { printf '%s\n' "$*" >&2; exit 1; }
3+
24
git clone https://github.com/AgoricBot/nat.git
3-
cd nat || exit
5+
cd nat || die "cd: nat failed"
46
git remote add upstream https://github.com/Agoric/nat.git
57
git remote set-url origin https://AgoricBot:$GITHUB_TOKEN@github.com/AgoricBot/nat.git
68
git fetch upstream
@@ -25,7 +27,7 @@ else
2527
fi
2628

2729
# Do the same thing with the package.json in the integration-test folder
28-
cd integration-test || exit
30+
cd integration-test || die "cd: integration-test failed"
2931
if npm audit ; then
3032
echo "Nothing to fix"
3133
else

scripts/npm-audit-fix.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
2+
die() { printf '%s\n' "$*" >&2; exit 1; }
3+
24
git clone https://github.com/AgoricBot/???.git
3-
cd ??? || exit
5+
cd ??? || die "cd: ??? failed"
46
git remote add upstream https://github.com/Agoric/???.git
57
git remote set-url origin https://AgoricBot:$GITHUB_TOKEN@github.com/AgoricBot/???.git
68
git fetch upstream

scripts/posttypedoc.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
2+
die() { printf '%s\n' "$*" >&2; exit 1; }
3+
24
(
3-
cd docs || exit
5+
cd docs || die "cd: docs failed"
46
find images -type f -print0 | xargs -0 tar c
57
) |
68
(
7-
cd api-docs || exit
9+
cd api-docs || die "cd: api-docs failed"
810
tar xv
911
)

0 commit comments

Comments
 (0)