anorack
anorack copied to clipboard
Return 1 on error?
Would it make sense to return 1 is a mistake is found?
anorack t ; echo $?
t:1: a ananas -> an ananas /an'A:n@z/
0
@tbm I was just about to report the very same issue. Great minds think alike, eh!? ;^)
@jwilk It would be nice to be able to use anorack as part of a Unix pipe from STDIN, i.e. in system manuals:
$ ... | while read man ; do man $man | anorack $man || echo $man ; done
Yes, the above pipeline is a naive one as it ignores manual pages of the same name but from a different sections, i.e. crontab(1) and crontab(5) - it is for demonstration purposes only.
Well, anorack did its job, so conceptually the exit status 0 sounds right.
I know some other code analysis tools return non-zero when they find something, so if any of you feel strongly about it, I guess I could be presuaded to follow the suit.
Or I could leave the current behavior, and add an option (say -e) to return non-zero if issues are found. Would that work for you?
In the mean time, you can use something like anorack ... | { ! grep ''; }, ideally preceded with set -o pipefail.
If it's all same to you I'd still vote for option 1 - return non-zero error code if an incorrect article has been found. It doesn't really need to be 1, in case you'd prefer to reserve it for other errors, i.e. runtime.
Alternatively, if you'd rather not change the program's default behaviour, -e would do.
I like the third option the least due to involvement of grep(1) as well as the fact that not all Unix shells support pipefail as it is not part of the POSIX standard... just yet.