Commit 84ca0c3
authored
style(shell): clear ShellCheck warnings in 7.0.4 openemr.sh and ssl.sh (#655)
## Summary
Slice 4 of the openemr-devops ShellCheck cleanup (follow-up to #649,
alongside #652 / #653). Resolves all 19 warnings in
`docker/openemr/7.0.4/openemr.sh` and both warnings in
`docker/openemr/7.0.4/ssl.sh`.
## Changes
- **New `docker/openemr/7.0.4/env.stub`** declares the 14 environment
variables both scripts read from the Docker runtime (set by
docker-compose `environment:` or `-e` flags): `K8S`, `SWARM_MODE`,
`MANUAL_SETUP`, `REDIS_SERVER`, `PHPREDIS_BUILD`, `PHP_VERSION_ABBR`,
`REDIS_USERNAME`, `REDIS_PASSWORD`, `REDIS_X509`, `REDIS_TLS`,
`XDEBUG_IDE_KEY`, `XDEBUG_ON`, `DOMAIN`, `OPERATOR`. Each is declared
with `: "${VAR:=}"` so the stub is a no-op when sourced and never
overrides real env values.
- **`# shellcheck source=docker/openemr/7.0.4/env.stub` directive**
added to both scripts, followed by `. /root/env.stub 2>/dev/null ||
true`. The directive path is repo-root-relative (matching how CI invokes
shellcheck and matching the pattern from #653); the runtime guard keeps
the script working inside the container image, where the stub is not
shipped. Clears all SC2154.
- **`openemr.sh` line 80 (SC2188 + SC3020):** replace `{ > FILE ; } &>
/dev/null` with `: > FILE 2>/dev/null`. POSIX-compliant no-op write with
redirected stderr; same intent (try to create the leader marker, fall
back to `AUTHORITY=no` on failure).
- **`openemr.sh` line 256 (SC3037):** replace `echo -n`
(POSIX-undefined) with `printf '%s'`.
- **`openemr.sh` line 287 (SC2312):** hoist `nproc --all` into a `jobs`
variable so `make -j "${jobs}"` no longer masks nproc's exit status.
- **`openemr.sh` noclobber block:** expand the "atomically test for
leadership" comment into a TOCTOU-vs-`O_CREAT|O_EXCL` explanation per
review.
- **`openemr.sh` SC2310 ×3** at the retry predicates `while swarm_wait`
(line 99) and `while ! auto_setup` (line 241): resolved with targeted `#
shellcheck disable=SC2310` plus a comment explaining the intent. The
predicates' failure is the loop-termination signal, not a script-fatal
condition, so the `set -e` suppression inside the `while` / `!` contexts
is the intended behaviour — a structural rewrite would invert the
retry-loop semantics.
## Verification
```
$ shellcheck --check-sourced --external-sources \
docker/openemr/7.0.4/openemr.sh \
docker/openemr/7.0.4/ssl.sh
```
is clean (exit 0).
## Test plan
- [x] `bash -n` clean on both scripts
- [x] `shellcheck --check-sourced --external-sources` clean on both
scripts
- [ ] CI ShellCheck workflow passes on this PR1 parent 494e47a commit 84ca0c3
3 files changed
Lines changed: 67 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
15 | 27 | | |
16 | 28 | | |
17 | 29 | | |
| |||
75 | 87 | | |
76 | 88 | | |
77 | 89 | | |
78 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
79 | 97 | | |
80 | | - | |
| 98 | + | |
81 | 99 | | |
82 | 100 | | |
83 | 101 | | |
84 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
85 | 107 | | |
86 | 108 | | |
87 | 109 | | |
| |||
224 | 246 | | |
225 | 247 | | |
226 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
227 | 253 | | |
228 | 254 | | |
229 | 255 | | |
| |||
253 | 279 | | |
254 | 280 | | |
255 | 281 | | |
256 | | - | |
| 282 | + | |
257 | 283 | | |
258 | 284 | | |
259 | 285 | | |
| |||
284 | 310 | | |
285 | 311 | | |
286 | 312 | | |
287 | | - | |
| 313 | + | |
| 314 | + | |
288 | 315 | | |
289 | 316 | | |
290 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
11 | 23 | | |
12 | 24 | | |
13 | 25 | | |
| |||
0 commit comments