bug-bash
[Top][All Lists]
Advanced

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

Re: simple function causes BASH to exit when -e in effect


From: Greg Wooledge
Subject: Re: simple function causes BASH to exit when -e in effect
Date: Fri, 22 Dec 2017 13:59:11 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Fri, Dec 22, 2017 at 10:56:18AM -0800, Kevin Layer wrote:
> The man page says:
> 
>     The shell does not exit if the command that fails is part  of  the
>     command list  immediately  following  a  while or until keyword,
>     part of the test  following  the  if  or  elif  reserved words,
>     part  of any command executed in a && or || list except the
>     command following the final  &&  or  ||,  any command  in a
>     pipeline but the last, or if the command's return value is being
>     inverted with !.
> 
> The fact that [ exits with 1 seems to be covered by the above passage for
> -e.

[ exits 1, but this doesn't trip -e because it's part of a compound
command.

However, debug1 also exits 1, and THAT trips -e, because debug1 is a
simple command.

debug2 does not exit 1 because "if" has completely different rules
compared to compound commands strung together with &&.

wooledg:~$ if false; then echo hi; fi
wooledg:~$ echo $?
0
wooledg:~$ false && echo hi; echo $?
1



reply via email to

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