Resolves https://github.com/kubernetes/kubernetes/issues/102975
shellcheck errors are printed to stdout by default, hence they need to be redirected
to stderr in order to be well parsed for Junit representation by `juLog` function.
Changelog:
https://github.com/koalaman/shellcheck/blob/master/CHANGELOG.md
We have some new erros due to the version bump.
- SC2034: VARIABLE_XYZ appears unused. Verify use (or export if used externally).
- Applies to all scripts we source in other scripts
- SC2039: In POSIX sh, set option pipefail is undefined.
- Applies to files using it with "sh" instead of "bash" in the shebang
- SC2054: Use spaces, not commas, to separate array elements.
- Fixing Should make no difference in the code
- SC2128: Expanding an array without an index only gives the first element.
- Fixing Should make no difference in the code
- SC2251: This ! is not on a condition and skips errexit. Use `&& exit 1` instead, or make sure $? is checked.
- Not 100% sure if we can swap to `&& exit 1`. Applies to a lot of
test code.
All changes should be straight forward to fix, but will be done in a
separate PR.
Some scripts contained `false` for returning 1 to callers instead of
`exit 1` and that works like:
$ false
$ echo $?
1
$
But that made confusion in a PR review process.
So this replaces `false` with `exit 1` for long-term maintenance.
The ./third_party/* directory contains scripts, libraries and
other components from external sources. These should be omitted
from lints and checks with the exception of things that are
forked and modified (located in ./third_party/forked/*) for
project related reasons.
Both verify-golint.sh and verify-shellcheck.sh have the same logic
which checks failure_file in alphabetical order.
In addition, we'd like to add another script which requires the
same logic. So this add a common function for cleanup.