bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FYI: do-release-commit-and-tag: fix typo


From: Akim Demaille
Subject: Re: FYI: do-release-commit-and-tag: fix typo
Date: Fri, 6 Jul 2012 09:52:23 +0200

Hi Eric,

Le 5 juil. 2012 à 17:28, Eric Blake a écrit :

> On 07/05/2012 09:16 AM, Akim Demaille wrote:
>> 
>> Le 5 juil. 2012 à 16:53, Jim Meyering a écrit :
>> 
>>> This script doesn't use set -e.
>>> I'd say that having to limit such use of "&&" is a good reason
>>> not to use "set -e".
>> 
>> In my experience, not setting set -e is asking for troubles.
>> I have been bitten way too often because of failures that go
>> unnoticed, and the script just continues.
> 
> In my experience, 'set -e' is worthless in any shell scripting mixed
> with functions.

This is really sad.  It's way too easy to miss checking for
errors in a shell script.  bootstrap for instance has two
mkdir not checked, one not being in a function.

The fact that set -e cannot help catching errors in shell
functions does not mean it is useless everywhere.

Actually, maybe there is some misunderstanding here.  I'm saying
set -e should always be set; not "rely on this
to avoid implementing explicit error handling".  My point is
that set -e has never caused me harm, but it definitely helped
my catch unnoticed errors in scripts.

Even in Makefiles actually.  Yesterday, in the flow of output
from "make beta" in Bison, by chance I spotted

        Unknown option: strip-cherry-picked

It turns out that the option is --strip-cherry-pick, but the Makefile
reads:

> gen-ChangeLog:
>       $(AM_V_GEN)if test -d $(srcdir)/.git; then              \
>         $(top_srcdir)/build-aux/gitlog-to-changelog           \
>           --strip-tab                                         \
>           --strip-cherry-picked                               \
>           --no-cluster                                        \
>           --amend=$(srcdir)/build-aux/git-log-fix             \
>           --since=$(gen_start_date) > $(distdir)/cl-t;        \
>         rm -f $(distdir)/ChangeLog;                           \
>         mv $(distdir)/cl-t $(distdir)/ChangeLog;              \
>       fi

Thanks to `;' this went unnoticed.  Of course now it reads:

> gen-ChangeLog:
>       $(AM_V_GEN)if test -d $(srcdir)/.git; then      \
>         cl=$(distdir)/ChangeLog &&                    \
>         rm -f $$cl.tmp &&                             \
>         $(top_srcdir)/build-aux/gitlog-to-changelog   \
>           --strip-tab                                 \
>           --strip-cherry-pick                         \
>           --no-cluster                                \
>           --amend=$(srcdir)/build-aux/git-log-fix     \
>           --since=$(gen_start_date) > $$cl.tmp &&     \
>         mv -f $$cl.tmp $$cl;                          \
>       fi

If Make was using set -e, this would have been noticed earlier.

Really, I much prefer using set -e and stating where
errors do not matter, rather than missing places where
errors did matter.

> 'set -e' can be useful in a strictly-controlled style of shell coding,
> but the POSIX rules on how it behaves are quite non-intuitive and cause
> more confusion than bugs that it would otherwise prevent by early exit
> on error; and my opinion is that while all errors should be detected,
> using 'set -e' as the crutch for the detection mechanism is bound to
> cause careless programming that is harder to fix than coding correctly
> in the first place.

So maybe we could have a better set -e live in Bash, and activate
that set -e only in that environment.  Sort of like using gccwarnings.m4.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]