-
-
Notifications
You must be signed in to change notification settings - Fork 557
Tidy shell scripts in ./bin #2256
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big improvement - thanks.
I've checked that, with this PR, shellcheck no longer complains:
$ git rev-parse --short HEAD
d74bb32c
$ shellcheck --version
ShellCheck - shell script analysis tool
version: 0.9.0
license: GNU General Public License, version 3
website: https://www.shellcheck.net
$ shellcheck bin/check_required_files_present bin/fetch-configlet bin/reorder-keys && echo 'success'
successI hadn't realized that the fetch-configlet script in this repo is so outdated. I'll PR to update it. It should use this version, like the track repos do.
Edit: I've created #2259. I'm happy for us to merge this PR as-is first, then rebase #2259 on top. But feel free to drop the fetch-configlet changes from this PR if you prefer. I wouldn't bother.
I've also intended to add shellcheck to CI in this repo, but apparently I never got around to it. I have it in Exercism repos that I maintain.
bin/check_required_files_present
Outdated
| if (( missing_files > 0 )); then | ||
| exit 1 | ||
| else | ||
| exit 0 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is exit "$(( missing_files == 0 ))" too obscure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer (( missing_files == 0 )); exit ... but being verbose here is probably good. It's longer but less likely to give anyone pause.
|
I'm quite happy letting the other PRs land first and rebasing this. |
* Prefer `[[` over `[`
* Expand tabs to 4 spaces
* Quote variables uniformly in `"${var}"` format
* Use `local` for function variables
* Prefer lowercase variable names for non-readonly variables
* Replace `let` with `$((`
* Format jq script
* Simplify logic
|
Rebased and I took a second pass. |
ee7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with some formatting suggestions.
I've checked that shellcheck is still happy.
Non-blocking comments:
- As a later follow-up, I would support renaming
bin/check_required_files_presenttobin/check-required-files-present, to matchbin/reorder-keys. - Again as a later follow-up, I'd probably support a PR that adds a script formatting check to CI. Something like:
shfmt -i 4 -ci -sr -kp. Or whatever. - There's maybe a slight precedent for preferring to indent bash scripts with 2 spaces: that's what the
fetch-configletscript (now) uses in this repo, and in every track repo. But that script will probably be removed from this repo, and I don't mind either way.
Co-authored-by: ee7 <[email protected]>
[[over["${var}"formatlocalfor function variablesletwith$((