-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
cmd/shfmt: --list exit code #1093
Comments
The use case would be:
vs .
in a Git pre-commit hook. Currently only With diff="$(shfmt --list $PWD)"
if [ -z "${diff}" ]; then
exit 0
else
exit 1
fi
|
There is some precedent with --diff using status codes; the There is less precedent with --list that I'm aware of, and I'm a bit worried about breaking users with the reasonable use case of listing unformatted files, but who don't want to treat the presence of them as a failure. They likely are still interested in existing failures such as invalid syntax, so ignoring the status code entirely is not a good solution. Personally, I think the "is empty" solution is good enough. It's pretty easy to do in shell and other programming languages. |
I'm going to close this as "won't fix" for now given the reasoning I gave above. |
-l
/--list
should also return1
.If you consider it a breaking API change you might want to introduce
--set-exit-if-changed
like google-java-format.The text was updated successfully, but these errors were encountered: