Commit 35c7b4b
authored
style(shell): declare runtime env via stub for ShellCheck (SC1091/SC2154/SC2312) (#653)
## Summary
Follow-up to #649. Resolves the remaining ShellCheck warnings in the
three `packages/standard` scripts that source `/root/cloud-variables` at
runtime: `ami-configure.sh`, `backup.sh`, and `restore.sh`.
`/root/cloud-variables` is written by CloudFormation UserData at
instance boot and is not tracked in the repo, so ShellCheck reports
SC1091 (not followable) and SC2154 (variables not assigned) for every
variable read from it.
## Changes
- **New `packages/standard/cloud-variables.stub`** declaring the
variables CFN injects (`DVOL`, `S3`, `KMS`, `RECOVERYS3`,
`RECOVERY_NEWRDS`) with no-op default assignments. The stub is a static
declaration only — it is never sourced at runtime; the real values still
come from CFN.
- **`# shellcheck source=packages/standard/cloud-variables.stub`**
directive added above each `source /root/cloud-variables` line. The path
is resolved from the repo root, matching how CI invokes shellcheck.
Clears SC1091 and all SC2154.
- **SC2312 hoists**: the remaining `return value masked in pipeline`
warnings in `ami-configure.sh` and `backup.sh` are fixed by capturing
the producing command's output into a variable, then feeding it to the
consumer via herestring. No runtime behavior change.
No `# shellcheck disable` directives are added; the stub plus `source=`
directive is the proper fix.
## Verification
```
$ shellcheck --check-sourced --external-sources \
packages/standard/ami/ami-configure.sh \
packages/standard/scripts/backup.sh \
packages/standard/scripts/restore.sh
$ echo $?
0
```
`bash -n` passes on all three scripts.
## Test plan
- [x] `bash -n` clean on all three scripts
- [x] `shellcheck --check-sourced --external-sources` produces no output
for the three files
- [ ] CI ShellCheck workflow passes on this PR1 parent 3f8ffb2 commit 35c7b4b
4 files changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
0 commit comments