[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash4: Problem retrieving "$?" when running with "-e"
From: |
John Kearney |
Subject: |
Re: Bash4: Problem retrieving "$?" when running with "-e" |
Date: |
Sat, 13 Apr 2013 01:41:49 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
Am 12.04.2013 18:26, schrieb Lenga, Yair:
> 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 PIPEr
> CMD_STAT=0 ; GET_MAIN_DATA || CMD_STAT=$?
That isn't a pipe its a logical or, it means if the first command
returns non 0 execute the next command.
as the assignment will not fail it avoids the problem.
as such you could also do
GET_MAIN_DATA || GET_BACKUP_DATA
or
if ! GET_MAIN_DATA ; then
GET_BACKUP_DATA
fi