Chet, Sorry again for pulling the wrong Bash 4 doc.
Based on the input, I'm assuming that the portable way (bash 3, bash 4 and POSIX) to retrieve $? When running under "-e" is to use the PIPE CMD_STAT=0 ; GET_MAIN_DATA || CMD_STAT=$? If [ "$CMD_STAT" = 11 ] ; then GET_BACKUP_DATA Fi Any other suggestion for portable code will be appreciated. Yair. -----Original Message----- From: Chet Ramey [mailto:chet.ra...@case.edu] Sent: Friday, April 12, 2013 11:16 AM To: Lenga, Yair [ICG-MKTS] Cc: 'bug-bash@gnu.org'; chet.ra...@case.edu Subject: Re: Bash4: Problem retrieving "$?" when running with "-e" On 4/12/13 7:44 AM, Lenga, Yair wrote: > The man page says that '-e' will "exit immediately if a simple command (note > Simple Command::) exits with non-zero status unless ...". > The "simple commands" definition is a "sequence of words separate by blanks > ...". According to this definition, the sequence "( simple command )" > Is NOT a simple command, and should NOT trigger the "immediate exit". > > Can anyone comment on my interpretation. Is there alternative solution > that will allow retrieval of the status of single commands when running With > the '-e' ? You appear to be using bash-4.x and reading the bash-3.x manual page. The bash-4.0 man page says Exit immediately if a \fIpipeline\fP (which may consist of a single \fIsimple command\fP), a \fIsubshell\fP command enclosed in parentheses, or one of the commands executed as part of a command list enclosed by braces (see .SM .B SHELL GRAMMAR above) exits with a non-zero status. The same language is in the man page through bash-4.2. There has been extensive discussion of the changes to -e between bash-3.2 and bash-4.0, which brought bash closer to Posix. Bash wasn't totally Posix-conformant until bash-4.2. See http://lists.gnu.org/archive/html/bug-bash/2012-12/msg00102.html for a summary. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/