Unix programs should avoid exiting non-zero for clever reasonsDan Astoorian's comment on yesterday's entry reminded me of this general issue, which I will phrase this way:
Unless you have a really good reason, your program should only ever exit non-zero if it has actually failed. Trust me; shell programmers are perfectly competent to check for some property of your output ourselves if we really want to know. (Even if you think you have a really good reason and a really important non-error thing to communicate with your non-zero exit status, you will make shell programmers very happy if you provide a command line switch to turn this behavior off so that you really truly only exit non-zero for real errors. The only exception if pretty much all possible uses of your program will have to examine your exit code to determine what to do next.) The poster child for an overly clever non-zero exit status is I am sure that a few shell script authors in the world have found this
convenient over the years, but I am equally sure that a lot more shell
script authors have wound up grimly guarding (Both have happened to us.) |
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |