-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gerard wrote: >> On December 09, 2007 at 04:19PM Micah Cowan wrote: > >> I believe I already answered this: it is because a non-zero exit status >> always means "something's wrong". Myriad scripts invoke utilities in >> ways similar to: >> >> if ! wget http://foo.com/ >> then >> echo "Something went wrong with the download." >> fi > > <snippet> > > wget http://foo.com > EC=$? > case $EC in > [0]) > bla bla bla > ;; > [1]) > bla bla bla > ;; > *) > more bla > ;; > esac > > A very simple way to handle an exit code. Place the entire code into a > function and it can be used anywhere in the script.
Fine. What about Hrvoje's more salient examples? "sh -e" or "wget -N foo || ..." The point is, just because some people may want to use your special if construct above, doesn't mean everyone should be made to. >> If Wget starts using non-zero to mean a "special" kind of success, >> scripting suddenly becomes much more complicated (and Wget suddenly >> ceases to be "Unixy"). > > The terminology here is incorrect. This is not a special kind of success. It > is simply exiting with a specific code defining what has transpired. This > makes scripting far easier. not more difficult. The condition is one of success, regardless of what code is issued. Issuing codes that indicate something other than success, when wget has done what you've asked, is wrong. And there is absolutely no way to interpret your "code 1" example (from another message) as anything other than success, in any case, so you're really not making your point very well. Non-zero exit statuses indicate failure, partial or complete. I am not going to try to use them to mean something else. Exit codes are, plain and simple, the wrong way to communicate these differences. Perhaps if, in the early days, the designers of Unix had had the foresight to partition exit codes a bit more equally between success and failure conditions, it would be different. As it is, such is not the case, and I am _not_ going to fudge things so that a few special cases are simpler, while complicating the more general cases. Now that we've established, rather clearly at this point, I think, what is _not_ going to be done, can we please leave this topic and continue onto the topic of what we _will_ do? - -- Micah J. Cowan Programmer, musician, typesetting enthusiast, gamer... http://micah.cowan.name/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHXGzh7M8hyUobTrERAitqAKCI7BSJrmirsmIAxzrXIvijpFHmHgCghVU6 qtEizoBNm6d/NBB/kGIVCnM= =Y26j -----END PGP SIGNATURE-----