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

Bug#568926: lintian seems to insist on set -e and doesn't like #!/bin/sh -e



Gerfried Fuchs <rhonda@deb.at> writes:

>  Ah, now I see the difference. Though, I'd like to challenge the
> explenation:

>  This is fine for normal operation, but if the script is run by
>  hand with "sh /path/to/script" (common in debugging), "-e"
>  will not be in effect.  It's therefore better to use "set -e" in
>  the body of the script.

>  This explenation assumes that all scripts are posix compliant shell
> scripts - which they don't have to be. They can be bash scripts or perl
> scripts too. Given that one *has* to check what type of script it is
> (like, head -1 script) it is directly visible from there that -e is set.

Hm, well, for maintainer scripts, I usually just use sh script, since
nearly all of them are POSIX.  But the same thing would apply if one
routinely ran bash script.  I don't recall ever running head -1 to see
what type of script it is unless that blew up.  (We do have some Perl
scripts, but they're fairly rare.)

The problem that Lintian is recommending to avoid is that since set -e
changes the behavior in some fundamental ways, it can happen that running
sh script will "work" when running the script directly doesn't, which is
very confusing.

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>



Reply to: