Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: Christoph Gysin Newsgroups: gnu.bash.bug Subject: command substitution is stripping set -e from options Date: Thu, 1 Oct 2015 13:24:18 +0300 Lines: 29 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: usenet.stanford.edu 1443724486 11246 208.118.235.17 (1 Oct 2015 18:34:46 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=Tgg7rZjCk6lPUCpX3bXmdMpw995fdUgNxgOtuc8aGz0=; b=cuJON5A5lbNOXOtEV488WPXuHNd0RfbM4TZAIxoG9hdYHCtJcwT+svF1RiUhRvOlr1 iqXJUz9uKowwJZK1r40FF0bw7SN648Nhjh91570tAOGfrQvbak9CVWlUzDESbeBLSJpF 2x2fcNZSo6gHta2pxIjaZsfMChWqaPTvQCJl0pbxW96cXKS2ugsED7Lu70VNOgfzPBfr 4f+HSINm6C62Xh1aT4SvPyGRtFdFEYG0Lcgq8Tt4SRvTmQVgSkwIWs+p6L+DfrO5IEwf WW2TU+MzPf55tyegZydb6Tq+hCyYop0tB4YEMCTRWOIcnJ6jZm4c2Aer3MN5NPgi8i7K zt+g== X-Received: by 10.25.19.73 with SMTP id j70mr1716823lfi.29.1443695097848; Thu, 01 Oct 2015 03:24:57 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::236 X-Mailman-Approved-At: Thu, 01 Oct 2015 13:50:37 -0400 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:11568 It seems that set -e is stripped from the options ($-) when executing commands with command substitution: $ bash -euc 'echo $-; f(){ false; echo $->&2; }; x=$(f)' ehuBc huBc I would expect the shell to exit as soon as it executes 'false'. Is this intended? Is it documented somewhere? I'm trying to catch errors in shellscripts by starting them with: set -euo pipefail It seems now that this is not enough, I would have to start every command substitution with set -e: var=$(set -e; command1; command2) It *seems* to work with only a single command, because the return value of the assignment is the last command executed inside the command substitution. But if there are multiple commands, or a function call, errors are not caught. Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3