OS400: fix shellcheck warnings in scripts

- use `$()` instead of backticks, and re-arrange double-quotes inside.
- add missing `|| exit 1` to `cd` calls. (could be dropped by using `set -eu`.)
- add `-n` to a few `if`s.
- shorten redirections by using `{} >` (as shellcheck recommended).
- silence warnings where variables were detected as unused (SC2034).
- a couple misc updates to silence warnings.
- switch to bash shebang for `-ot` feature.
- split two lines to unbreak syntax highlighting in my editor. (`$(expr \`, `$(dirname \`)

Also enable CI checks for OS/400 shell scripts.

Ref: #13307
Closes #13309
This commit is contained in:
Viktor Szakats 2024-04-07 12:39:59 +00:00
parent 8dd81bd5db
commit 8a622baf9e
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
8 changed files with 106 additions and 92 deletions

View file

@ -3,10 +3,8 @@
#
# SPDX-License-Identifier: curl
# FIXME: packages/OS400/* scripts
shellcheck --version
# shellcheck disable=SC2046
shellcheck --exclude=1091 \
--enable=avoid-nullary-conditions,deprecate-which \
$(grep -l -E '^#!(/usr/bin/env bash|/bin/sh|/bin/bash)' $(git ls-files | grep -v -F 'packages/OS400/'))
$(grep -l -E '^#!(/usr/bin/env bash|/bin/sh|/bin/bash)' $(git ls-files))