[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request: more complete set -e
From: |
Marc Weber |
Subject: |
Re: feature request: more complete set -e |
Date: |
Thu, 25 Jun 2009 00:26:56 +0200 |
User-agent: |
Mutt/1.5.16 (2007-06-09) |
On Tue, Jun 23, 2009 at 09:00:10AM -0400, Chet Ramey wrote:
> Marc Weber wrote:
> > Hi,
> >
> > I stumbled about another bash problem today:
> >
> > for item in $(false);
> > echo $item
> > done || { echo for failed; }
> >
> > doesn't fail. I think it's bad that there is no
> > set -e
> >
> > like switch which really catches all failures of this kind.
>
> This isn't really about set -e or ||; the for loop doesn't fail.
>
> Posix.2 says, in part,
>
> "[T]he list of words following in shall be expanded to generate
> a list of items...If there are no items, the exit status shall
> be zero."
>
> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_03
This is my point: I'd like to tell bash: Whenever running an executable
assume that if it returns a non zero exit status that's a unforeseen
exception. And in this case don't continue as usual but abort and return
non zero exit status yourself. set -e comes close.
Maybe this is not posix compliant. But I think it would be useful to
have this kind of propagating error conditions in all cases.
Of course for i in $(echo ""); .. ; done should still result in exit
status 0. But if echo was an executable failing due to any reason (eg
segmentation fault) there should be a way to make the script fail
without having to remember that a dummy var has to be used like this:
dummy=$(fail)
for i in $dummy; do .. ; done
I'm only one user in the world and I can't say what all bash users want.
I'd like to see this feature making my script yell if there is an
exception.
I don't want to offend bash. I want to see it turning into a fool
proof direction because bash is not the only language I have to use
which makes it harder to remember all details.
Sincerly
Marc Weber
- feature request: more complete set -e, Marc Weber, 2009/06/22
- Re: feature request: more complete set -e, Chet Ramey, 2009/06/23
- Re: feature request: more complete set -e,
Marc Weber <=
- Re: feature request: more complete set -e, Chet Ramey, 2009/06/25
- Re: feature request: more complete set -e, Marc Weber, 2009/06/28
- Re: feature request: more complete set -e, Greg Wooledge, 2009/06/29
- Re: feature request: more complete set -e, Chet Ramey, 2009/06/29
- Re: feature request: more complete set -e, Bob Proulx, 2009/06/29
- Re: feature request: more complete set -e, Marc Weber, 2009/06/30
- Re: feature request: more complete set -e, Greg Wooledge, 2009/06/30
- Re: feature request: more complete set -e, Chet Ramey, 2009/06/30