-
-
Notifications
You must be signed in to change notification settings - Fork 321
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
fix: Run shellcheck on hledger-bar #2159
Conversation
Thanks @colindean ! I never knew shellcheck could do that. When I check it in master there's one shellcheck warning:
which I've just pushed a fix for. The homebrew error seems like something caused by a different shell version, but I'm not sure what it could be. Testing here with |
Found it! Now fixed in master. hledger-bar was broken if $NO_COLOR was not defined. Thanks for the bug report. |
…2159] Also, it's now more compliant with the no-color.org spec: Command-line software which adds ANSI color to its output by default should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color. so one can now temporarily override $NO_COLOR=1 in the environment by setting it empty: NO_COLOR= hledger ...
It's a great tool, opinionated in that it never itself can modify code under inspection, unlike many if not most other linters. There are some idiosyncracies of doing I've got something like this in many of my projects including shell files: .PHONY: format-sh
format-sh: $(SHELL_FILES)
$(SHELLCHECK) --shell=bash --enable=all --format=diff $(SHELL_FILES) | git apply
You'll see more if you pass
I'll have to dig into it a little more if the next hledger release to include bd8bd39 doesn't fix the problem. |
You'll see more if you pass --enable=all. This PR addressed all of them, which were all autocorrectable.
Aha. If you care to repeat this for latest master and re-push, I'll merge it.
|
Done! Shellcheck doesn't like the bare |
Would you mind rebasing it to one clean commit. (git rebase locally, then git push -f) |
c0b817d
to
bbad17c
Compare
I [encountered][1] an unexpected error when testing hledger-bar for proposed inclusion in Homebrew's default installation of hledger: /opt/homebrew/Cellar/hledger/1.32.2_1/bin/hledger-bar: line 81: conditional binary operator expected I'm doubt that this is fixed by running shellcheck, but checking a script against shellcheck is usually one of the first things I check before debugging shell! This patch is ~generated by shellcheck with shellcheck --shell=bash --enable=all --format=diff bin/hledger-bar | \ git apply plus some extra, manual additions in the form of a shellcheck directive to accept something that's a little abnormal for shellcheck but fine here. The `set -o inherit_exit` was also recommended by shellcheck. [1]: https://github.com/Homebrew/homebrew-core/actions/runs/7606843601/job/20713321881?pr=160590
bbad17c
to
a3cde31
Compare
Rebased! |
…2159] Also, it's now more compliant with the no-color.org spec: Command-line software which adds ANSI color to its output by default should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color. so one can now temporarily override $NO_COLOR=1 in the environment by setting it empty: NO_COLOR= hledger ...
…imonmichael#2159] Also, it's now more compliant with the no-color.org spec: Command-line software which adds ANSI color to its output by default should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color. so one can now temporarily override $NO_COLOR=1 in the environment by setting it empty: NO_COLOR= hledger ...
I encountered an unexpected error when testing hledger-bar for
proposed inclusion in Homebrew's default installation of hledger:
I'm doubtful that this is fixed by running shellcheck, but checking
a script against shellcheck is usually one of the first things I check
before debugging shell!
This patch is ~generated by shellcheck with