shellcheck/shfmt more files; run check-config in CI#3378
shellcheck/shfmt more files; run check-config in CI#3378thaJeztah merged 7 commits intoopencontainers:mainfrom
Conversation
7573e7e to
60581d8
Compare
60581d8 to
ff7541c
Compare
ff7541c to
eabfd7f
Compare
|
@tianon PTAL 🙏🏻 |
tianon
left a comment
There was a problem hiding this comment.
Hopefully my suggestions on these PRs aren't making you regret asking me for my thoughts on them 😂 😇
Generally speaking, I try to avoid bash-isms unless they provide obvious value (or I know for certain the script will never want or need to become /bin/sh). This makes sure that when I do have to write /bin/sh (such as in Dockerfile RUN lines 😅), I'm not constantly getting the syntax wrong because my muscle memory is already mostly right. 😄
| search_config() { | ||
| local target_dir="$1" | ||
| [[ "$target_dir" ]] || target_dir=("${possibleConfigs[@]}") | ||
| local target_dir=("${1:-${possibleConfigs[@]}}") |
There was a problem hiding this comment.
I wasn't sure if the quoting here would have the right effect, but it appears that it does!
$ arr=( 'foo bar' 'baz' ); foo() { local foo=("${1:-${arr[@]}}"); local bar; for bar in "${foo[@]}"; do echo "$bar"; done; }; foo bar; foo
bar
foo bar
baz| } | ||
|
|
||
| if [ "$kernelMajor" -lt 4 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -le 5 ]; then | ||
| if [ "$kernelMajor" -lt 4 ] || [[ "$kernelMajor" -eq 4 && "$kernelMinor" -le 5 ]]; then |
There was a problem hiding this comment.
| if [ "$kernelMajor" -lt 4 ] || [[ "$kernelMajor" -eq 4 && "$kernelMinor" -le 5 ]]; then | |
| if [ "$kernelMajor" -lt 4 ] || { [ "$kernelMajor" -eq 4 ] && [ "$kernelMinor" -le 5 ]; }; then |
eabfd7f to
f74a613
Compare
|
@tianon addressed all your comments; PTAL |
f74a613 to
486c737
Compare
|
Nice! I love how much cleaner your |
|
@thaJeztah @AkihiroSuda PTAL |
|
@thaJeztah @AkihiroSuda PTAL (this was already blessed by @tianon) |
486c737 to
478989e
Compare
|
Rebased (no changed, just a merge conflict in |
…and fix a single format issue found. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. Allow wrap_bad and wrap_good to have an optional arguments.
2. Remove unneeded echos; this fixes the shellcheck warnings like
In ./script/check-config.sh line 178:
echo "$(wrap_bad 'cgroup hierarchy' 'nonexistent??')"
^-- SC2005 (style): Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
3. Fix missing color argument in calls to wrap_color (when printing the
hint about how to install apparmor).
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Like this one: In ./script/check-config.sh line 215: if [ "$kernelMajor" -lt 5 ] || [ "$kernelMajor" -eq 5 -a "$kernelMinor" -le 1 ]; then ^-- SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
... and add this file to shellcheck target in Makefile.
These:
In script/check-config.sh line 27:
kernelMinor="${kernelVersion#$kernelMajor.}"
^----------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.
Did you mean:
kernelMinor="${kernelVersion#"$kernelMajor".}"
In script/check-config.sh line 103:
source /etc/os-release 2>/dev/null || /bin/true
^-------------^ SC1091 (info): Not following: /etc/os-release was not specified as input (see shellcheck -x).
In script/check-config.sh line 267:
NET_CLS_CGROUP $netprio
^------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
One particularly bad one is ${codes[@]} which is fine in bash 4.4+,
but gives "codes[@]: unbound variable" with older bash versions,
such as with bash 4.2 used on CentOS 6. It's good that this is the only
array in the script that can potentially be empty.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This is done to make sure the script is working correctly in different environments (distro and kernel versions). In addition, we can see in test logs which kernel features are enabled. Note that I didn't want to have a separate job for GHA CI, so I just added this to the end of shellcheck one. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Now the only remaining file that needs shellcheck warnings to be fixed is bash-completion. Note that in Makefile's TODO. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
478989e to
ae6cb65
Compare
|
Rebased; PTAL @AkihiroSuda |
|
Do I still need to address anything in this PR? PTAL @thaJeztah @AkihiroSuda @opencontainers/runc-maintainers |
This almost fixes the TODO item for shellcheck.
Please review commit-by-commit; see individual commits for details.