nil
nil copied to clipboard
Wrong return code on nil diagnostics
When I run nil diagnostics <file-name> on a file with only warnings the help util says:
Exit with non-zero code if there are any diagnostics. (
1for errors,2if only warnings)
But when there are only warnings it returns 0.
The bug might be in this piece of code
Hey there, just stumbled on this randomly, and I'm also the author of the code you're referring to.
It's in fact the wanted behaviour we ended up deciding for in this discussion - gist:
To me, warnings should not be errors. We can just change the default behavior here to make it returns non-zero only on errors. Users who want the old deny-all behavior can still check if stdout is empty anyway. What do you think?
I did in fact, forget to update the help/documentation I had changed before :sweat_smile:
If the help would explain the current behaviour correctly, would it still be an issue for you? i.e. can you just check for empty output in your use-case where you need to know about warnings?
Hey! Thanks for your reply. It's good enough for me and I understand your point of view.
My only concern is trust in the output to check something (i.e. if it has warnings, some output will be printed) :/
But as you discussed, having the option to say that warnings are errors is the best.
I was surprised to notice that my git pre-commit hooks do not complain about warnings.
I think it would be nice to make this configurable, like exit with 0 by default when there's only warnings, but accept an option like --fail-on-warnings or such to have nil exit with another error code if desired.
Workaround: ! nil | grep .
But yeah..