WPB-2568 Fix shellcheck linting problems on all shell scripts#4220
WPB-2568 Fix shellcheck linting problems on all shell scripts#4220
Conversation
|
It is annoying that this wouldn't respect gitignore and could overwrite files in dist-newstyle, etc. I am looking into why it the git walker doesn't work. So far I have found this: Running But if we ask git about how many files it has by running When using the I didn't want us to find weird problems in future so I did a a timeboxed stare at treefmt's code and found that this code basically ignores any file which doesn't have the mode |
|
Can we please not do the changes to treefmt args and instead do either of these things:
Thanks a lot for fixing all the shellscripts tho ❤️ |
|
I cut a new release, which includes the fix for this: https://github.com/numtide/treefmt/releases/tag/v2.0.5. You can wait until it propagates through Hydra, or add |
hack/bin/create_test_user.sh
Outdated
There was a problem hiding this comment.
do you really need to enter and exit the quoted state for the commas here? i don't believe they will be considered part of the variable names...
There was a problem hiding this comment.
Yep, correct, they are not needed. Fixed in 8a1940c
julialongtin
left a comment
There was a problem hiding this comment.
some of these changes with quotes look suspicious to me...
d49b78b to
2ad0862
Compare
|
After rebasing on bumped nixpkgs we can use --walk=git to match all our scripts. Randomly requested review from people I know that know bash |
lwille
left a comment
There was a problem hiding this comment.
I might have found some issues, can you have a look?
| SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| cd "$SCRIPT_DIR/../../.local/charts" |
There was a problem hiding this comment.
thought: This seems a bit convoluted to me: we temporarily change directory just to print its name, then cd into that again.
suggestion: I think using dirname and realpath should do the same thing, are easier to understand and thus common practice:
| SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |
| cd "$SCRIPT_DIR/../../.local/charts" | |
| SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") | |
| cd "$SCRIPT_DIR/../../.local/charts" |
There was a problem hiding this comment.
the solution is from https://stackoverflow.com/questions/59895/how-do-i-get-the-directory-where-a-bash-script-is-located-from-within-the-script It probably went through a lot of discussion, so I wouldn't wanna change it
tools/sftd_disco/sftd_disco.sh
Outdated
| comma="" | ||
| IFS=$'\n' | ||
| for entry in ${entries[@]}; do | ||
| for entry in "${entries[@]}"; do |
There was a problem hiding this comment.
issue: same thing here: the array is expanded inside the quotes, so you just get one entry with all records inside.
suggestion: don't quote ${entries[@]}, however use quoting when using $entry (as you did down the line).
| for entry in "${entries[@]}"; do | |
| for entry in ${entries[@]}; do |
There was a problem hiding this comment.
Thank you for checking! No, actually array quoted arrays are still splitting, and shellcheck suggests it https://www.shellcheck.net/wiki/SC2068
The problem here is that entries is not array, but a string. Applied your suggestsions in 88b16c8
This PR activates shellcheck linting for almost all shell scripts.
It also fixes various suggestions on the shell scripts that are now shellchecked.
Tracked by https://wearezeta.atlassian.net/browse/WPB-2568
Current sprint: https://wearezeta.atlassian.net/browse/WPB-9757
Checklist
changelog.d