help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] set -e and CMD_IGNORE_RETURN question


From: Greg Wooledge
Subject: Re: [Help-bash] set -e and CMD_IGNORE_RETURN question
Date: Wed, 7 Mar 2018 14:44:19 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Mar 07, 2018 at 09:18:25PM +0500, Kolya wrote:
> I have many troubles, when call function inside test statement, or something
> like this:
> 
> set -e

http://mywiki.wooledge.org/BashFAQ/105

> f && echo ok

The -e will not trigger during f because this is not a simple command.

> I understand the mail logic of how it work.

I don't understand what "mail logic" means.

> Question is: this is bash-interpreter coding problem only, or something
> else?

It is how POSIX defines set -e to work, which is based on the historical
usage of this misfeature.  It is not what you think it is.  It exists
only to support the continued lurching and shambling of legacy scripts.

> Can me (or someone) do new option, like set -e, what won't be ignored
> inside functions?

Sure!  It's called doing the actual work yourself.


f() {
   critically-important-command || return 1
   command-that-depends-on-previous-command-success
}

f && echo ok


Error checking in languages like bash and C is done by YOU, the
programmer.  There are no automatic features for it.  Put those checks
in yourself.

Once again, please see http://mywiki.wooledge.org/BashFAQ/105



reply via email to

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