-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shellcheck and various other oddities #15
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Argument to -z is always false due to literal strings. Signed-off-by: Randolph Sapp <[email protected]>
Using "$@" will prevent unnecessary splitting of quoted parameters. For instance, if the following parameter was passed previously: "-a 'hello world'" it would be split into "-a" "hello" "world" which could break things later in processing. The kernel_patch_verify script will have to be reworked to deal with this independently as a lot of functions inherently rely on splitting for handling arrays. Signed-off-by: Randolph Sapp <[email protected]>
Paths mentioned in the `PATH` env variable should not end with `/`. Signed-off-by: Randolph Sapp <[email protected]>
Fix shellcheck warning about word splitting by making the split explicit. Signed-off-by: Randolph Sapp <[email protected]>
Signed-off-by: Randolph Sapp <[email protected]>
Use $(...) notation instead of legacy backticks `...`. Signed-off-by: Randolph Sapp <[email protected]>
Signed-off-by: Randolph Sapp <[email protected]>
Split the current `download_and_install_armgcc` function into a `download_and_install_armgcc_64` and `download_and_install_armgcc_32`. Signed-off-by: Randolph Sapp <[email protected]>
Standardize all functions on the use of FILE and URL variables. Signed-off-by: Randolph Sapp <[email protected]>
Signed-off-by: Randolph Sapp <[email protected]>
Paths mentioned in the `PATH` env variable should not end with `/`. Signed-off-by: Randolph Sapp <[email protected]>
Use $(...) notation instead of legacy backticks `...`. Signed-off-by: Randolph Sapp <[email protected]>
Fix word splitting issues that may arrise from docker mount parameters and other variables. Signed-off-by: Randolph Sapp <[email protected]>
Split the common code out into a file both scripts source. Signed-off-by: Randolph Sapp <[email protected]>
Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. Signed-off-by: Randolph Sapp <[email protected]>
Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. Signed-off-by: Randolph Sapp <[email protected]>
Use $(...) notation instead of legacy backticks `...`. Also fix the arithmetic sections. Signed-off-by: Randolph Sapp <[email protected]>
Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. Signed-off-by: Randolph Sapp <[email protected]>
Use printf and some short templates to remove some redundant sections. Signed-off-by: Randolph Sapp <[email protected]>
Use static strings for the grep expressions not using variables. Make sure some reserved characters are escaped properly. Signed-off-by: Randolph Sapp <[email protected]>
These instances of subshell execution have ((, which is the starting parameter for arithmetic operations. Make sure everything's padded well enough to prevent misinterpretation. Shells disambiguate (( differently or not at all. For subshell, add spaces around ( . For ((, fix parsing errors. Signed-off-by: Randolph Sapp <[email protected]>
Use glob instead of ls and print the files we get from that instead of attempting to reindexing them. Signed-off-by: Randolph Sapp <[email protected]>
I know right now docker ignores "-v : " but I do not want to see what happens if this ever changes. Besides, we can't do anything if we're not working in a git directory anyway. Signed-off-by: Randolph Sapp <[email protected]>
This just pruned stopped containers and dangling images before removing the built container. Use the official commands for these operations. Signed-off-by: Randolph Sapp <[email protected]>
Quote everything currently not relying on word splitting. Signed-off-by: Randolph Sapp <[email protected]>
Implied that the script exits 0 by default. With this shellcheck considers some of the code unreachable. Drop it so we can check on things. Signed-off-by: Randolph Sapp <[email protected]>
Replace all of the loose parameter passing with strict array packing and unpacking. Signed-off-by: Randolph Sapp <[email protected]>
To redirect stdout+stderr, 2>&1 must be last Signed-off-by: Randolph Sapp <[email protected]>
Cat is really only good for concatenating files. If we only want to read files we can use bash and printf directly. More keystrokes but faster at runtime than cat. Signed-off-by: Randolph Sapp <[email protected]>
Use -print0 and -0 when piping from find into xargs. Signed-off-by: Randolph Sapp <[email protected]>
Avoid x-prefix in comparisons as it no longer serves a purpose. Signed-off-by: Randolph Sapp <[email protected]>
egrep is non-standard and deprecated. Use grep -E instead. Signed-off-by: Randolph Sapp <[email protected]>
Reduce the number of redirects with subshell execution. Signed-off-by: Randolph Sapp <[email protected]>
Read without -r will mangle backslashes. We don't have to let wc count characters in a variable. Signed-off-by: Randolph Sapp <[email protected]>
StaticRocket
force-pushed
the
shellcheck
branch
from
March 15, 2024 04:20
750b693
to
7c3f06a
Compare
I'd like to thank the Ballmer Peak for this hellish PR. Have fun! |
Got 3 more planned reworks for this tool after this series:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Waste a Saturday fixing shellcheck warnings.
I've got another series in progress that reworks the patch logic since the application process is the same no matter what path is taken. Unfortunately I got distracted trying to simplify the current argument parsing as that's a little odd.
Eventually I'll see if I can integrate my common entrypoint script to cut out the image generation segment in
kp_common
.