Repository navigation
Description
On branch carry at f7927f8, the repository lint fails on bin/fm-dod-lib.sh. Public main at 427056c has no fm_brief_switch_delivery: the function came with "Switch a live ship's delivery mode through relaunch --mode (#26)" (cb9ef48).
Reproduce in a clean clone
git clone --branch carry https://github.com/guybeju/firstmate firstmate-carry
cd firstmate-carry
git rev-parse HEAD # f7927f826696c016da3ca4df9bd28b8f428da30e
bash bin/fm-lint.sh bin/fm-dod-lib.sh; echo "rc=$?"With ShellCheck 0.11.0, the pinned version, the lint reports these warnings and exits 1:
In bin/fm-dod-lib.sh line 409:
FM_BRIEF_SWITCH_FROM=$from
SC2034 (warning): FM_BRIEF_SWITCH_FROM appears unused.
In bin/fm-dod-lib.sh line 426:
new_setup=... new_ask=... new_dod=...
SC2034 (warning) for new_setup, new_ask, new_dod.
In bin/fm-dod-lib.sh line 428:
old_setup=... old_ask=... old_dod=...
SC2034 (warning) for old_setup, old_ask, old_dod.
rc=1
Every flagged variable is read
| Variable (assigned at) | Where it is read |
|---|---|
new_setup, new_ask, new_dod (bin/fm-dod-lib.sh:426) |
bin/fm-dod-lib.sh:438 ${!new}, where line 436 sets new="new_$name" for name in setup ask dod (line 435) |
old_setup, old_ask, old_dod (bin/fm-dod-lib.sh:428) |
bin/fm-dod-lib.sh:433 and 438 ${!old}, where line 436 sets old="old_$name" |
FM_BRIEF_SWITCH_FROM (bin/fm-dod-lib.sh:409) |
bin/fm-control.sh:1270-1271. fm-control.sh sources the library (line 218) and calls fm_brief_switch_delivery ... > "$SWITCH_BRIEF" at line 1268. That is a redirect, not a command substitution, so the global is set in the caller's shell. |
ShellCheck does not follow ${!name} indirection, and when it lints the library on its own it does not see reads made by a caller. So these are false positives.
The function itself works. bash tests/fm-dod-lib.test.sh on the same clean clone passes, including:
fm_brief_switch_delivery: a switched scaffold equals a fresh scaffold of the other mode ..., which needs the old and new values;fm_brief_switch_delivery: refuses an external forge, a missing Captain's intent, and an ambiguous contract.
The cross-file read of FM_BRIEF_SWITCH_FROM is shown here by reading the code, not by a test.
Expected
bin/fm-lint.sh bin/fm-dod-lib.sh exits 0, as it does for every file on public main.
Possible fix (untested)
Elsewhere this repository silences the same kind of warning with a reasoned directive. For example, bin/fm-classify-lib.sh:123 has # shellcheck disable=SC2034 # Read by the watcher and daemon ..., not this lib. A directive like that above lines 409, 426 and 428 should clear the lint. This fix has not been tested.
Activity
guybeju commentedon Nov 17, 2026
Fixed by #43 (merged into carry).
bash bin/fm-lint.sh bin/fm-dod-lib.shexits 0 with ShellCheck 0.11.0 at the merge.