[Toybox] Command exit numbers.
Rob Landley
rob at landley.net
Sat Jun 10 11:29:23 PDT 2017
Would it be useful if perror_exit() set exitval to errno by default
instead of 1? They're well defined values that let you know _what_ happened.
I just fixed grep so it doesn't error_exit() when it hits a dangling
symlink (because fdopen() failed to covert fd to file *), but
perror_msg() sets errno to 1, and "grep -rq blah" has 1 mean "didn't
find what we were grepping for". In this instance, finding it stops and
returns 0 immediately so if you hit one of those it won't change the
results, but the caller can't distinguish "did not find" from "hit
dangling symlink and wanted to report it as an error" unless they
capture stderr. In this case that's probably fine, but it made me think
about the more general problem.
The downside would be other commands that use error return values other
than 0 and 1 already. This could create false positives for that.
*shrug* Thought I'd ask. I still have this annoying cold and trying to
think through it myself right now isn't getting a lot of traction.
Rob
More information about the Toybox
mailing list