Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: Christoph Gysin Newsgroups: gnu.bash.bug Subject: Re: command substitution is stripping set -e from options Date: Fri, 2 Oct 2015 14:09:21 +0300 Lines: 41 Approved: bug-bash@gnu.org Message-ID: References: <560D83DA.9020405@redhat.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: usenet.stanford.edu 1443788211 12140 208.118.235.17 (2 Oct 2015 12:16:51 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Eric Blake Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=P/B2ntnSVRY1ZTuirnybEVkeM8T2Vo6r2PwtPDAanTQ=; b=m/yUTqz8oSjHkVk3Z5ZPNkyTrw6l4QIhi1I9RTxETq7/Mc9/PAV6V8S6z2fQUgLf5a YWlNvjRww4QJHM57HJBuTvuMH23SbVpRMIBPeMBgWtC69bhQVuqr7YZ12A2D079p1WDa TRtz16Lr1DKyZoVTysIfRG7QPwnnT3DsFYGVp1OpRNTTXwpeeL9244Bz4RTr0mUO5vp0 yrWT+QuVgGeORgXLMorh9zuecVHbyP+Ln+pRByTrRyO5ZMvpD5uSCtOakAneS8uXWl/Q n+iG/05mfn6ZnlSm1V+BSH7ZrxvecAyY/CP8nru6BZIQVsqKAT2l/f1SwCs0zyTYzNjf R+9A== X-Received: by 10.112.139.201 with SMTP id ra9mr5246361lbb.29.1443784200440; Fri, 02 Oct 2015 04:10:00 -0700 (PDT) In-Reply-To: <560D83DA.9020405@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22f X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11572 > Whether e disappears from $- may be unintended, but what IS documented > is that there are contexts in which set -e has no effect, and when in > one of those contexts, you cannot re-enable set -e. One such context is > on the left side of && or ||. Even more non-intuitively, if you have a > function that tries to use set -e, the effect of set -e depends on the > context of where the function is called (that is, 'f' may behave > differently than 'f || true'). Yes, I'm aware of all those, and I think they make sense. They are also documented. > What's wrong with: > var=$(command1 && command2) || exit Because the code is: f() { some command more commands --with-args } output=$(f) Since set -e does not work, it means I have to postfix every command with "|| exit $?": f() { some command || exit $? more commands --with-args || exit $? } output=$(f) My understanding was the the whole point of set -e was to have that behaviour by default for every command (with the documented exceptions). Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3