Bug#139969: debian-policy: dubious shell programming advice re: set -e [patch included]
>>"era" == era eriksson <era@iki.fi> writes:
era> The sections which recommend the use of set -e are IMHO a bit off the
era> mark. The recommendations imply that failing silently is a Good Thing
era> and that not handling errors sensibly is okay in shell scripts.
Really? If you do not set -e, it is easier to handle errors?
How is that? Withiut set -e we may never even know there is an error
era> In summary, relying on set -e to trap your errors for you
era> results in counter-intuitive behavior from the end user's
era> perspective.
set -e does not, in the normal sense of the word, trap
errors. It causes your script to handle errors that would otherwise
be missed. So, set -e actually detects error otherwise missed, and
while you say you want errors detected and handled, you are actually
making the situation worse.
era> If the init.d script just runs and doesn't tell you
era> the program you wanted to start is not available, is that good
era> behavior?
Indeed. It is also required behaviour. I may have removed (put
not purged) the package, and would not like the init script to bitch
and moan about it.
era> If the script just dies silently when your disk fills
era> up, is that good behavior? No, these errors should be trapped
era> and at least result in a warning message.
I think set -e is orthogonal to error handling. using set -e
makes one handle the errors -- for set -e does end execution with an
failed status on error.
era> (For example, I have filed a bug against e.g. the `bug' package for an
era> issue which is more or less caused by the present policy; see bug
>> 76127. I suspect there will be many more which just wait to be
era> discovered.)
Well, it would be nice to handle all possible errors, yes. But
in this case it was not a set -e that caused the problem, it was the
fact that the result was indistinguishable from a user not adding
anything to the report.
Having file systems full is an exceptional condition, and like
all unusual error conditions, may not be fully detected.
Removing error detection with set -e makes things worse.
era> As a proposed fix, I have reworded some parts of the policy, as
era> included in the patch below. This modifies the "should" and adds a
era> "may", with some related changes in earlier sections of the manual. I
era> also took the liberty to add comments to the /etc/init.d/bind example
era> where it breaks the new recommendation.
And would make policy inconsistent with itself.
manoj
--
Date: 28 Mar 90 18:06:57 GMT From: merlyn@iwarp.intel.com (Randal
Schwartz) $_ = "Just a sed
user,";s/a/another/;s/sed/Perl/;s/user/hacker/;print
Manoj Srivastava <srivasta@debian.org> <http://www.debian.org/%7Esrivasta/>
1024R/C7261095 print CB D9 F4 12 68 07 E4 05 CC 2D 27 12 1D F5 E8 6E
1024D/BF24424C print 4966 F272 D093 B493 410B 924B 21BA DABB BF24 424C
--
To UNSUBSCRIBE, email to debian-policy-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: