RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 590740 - 'set -e' works strange inside the subshell
Summary: 'set -e' works strange inside the subshell
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: bash
Version: 6.0
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Roman Rakus
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-05-10 15:21 UTC by Kirby Zhou
Modified: 2014-01-13 00:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-05-11 18:28:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Kirby Zhou 2010-05-10 15:21:10 UTC
Description of problem:

'set -e' works strange inside the subshell.

I think (set -e; ... ) should keep behavior invariantly with different contexts, but it does not. Sometimes 'set -e' is ignored with '&&'/'||' around the bracket.

In my opinion, all cases below should not execute 'echo norun', but some cases did run it.

Version-Release number of selected component (if applicable):

bash-4.1.2-2.el6.x86_64

How reproducible:

100%

Steps to Reproduce:

]# (set -e -x ; false ; echo norun ) || true
+ false
+ echo norun

]# (set -e -x ; false ; echo norun ) && true
+ false
+ echo norun

]# ! (set -e -x ; false ; echo norun )
+ false

]# false || (set -e -x ; false ; echo norun )   
+ false

]# true && (set -e -x ; false ; echo norun )  
+ false

]# (set -e -x ; false ; echo norun ) 
+ false

Comment 2 RHEL Program Management 2010-05-10 16:54:28 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.

Comment 3 Roman Rakus 2010-05-11 18:28:36 UTC
This is nicely documented. See man page of set builtin;
-e      Exit immediately if a pipeline (which may consist  of  a
                      single  simple command),  a subshell command enclosed in
                      parentheses, or one of the commands executed as part  of
                      a  command  list  enclosed  by braces (see SHELL GRAMMAR
                      above) exits with a non-zero status.  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 !.  A trap on ERR,
                      if set, is executed before the shell exits.  This option
                      applies to the shell environment and each subshell envi-
                      ronment separately (see  COMMAND  EXECUTION  ENVIRONMENT
                      above), and may cause subshells to exit before executing
                      all the commands in the subshell.


Note You need to log in before you can comment on or make changes to this bug.