[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Doc on simple command expansion
From: |
Chet Ramey |
Subject: |
Re: Doc on simple command expansion |
Date: |
Fri, 4 Mar 2022 08:58:09 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 |
On 3/3/22 9:42 PM, Glen Huang wrote:
I'm still wondering if it's possible to make bash exit at "false" in
echo $(false)? Simple "set -e" doesn't seem to cut it.
It is not. When there is a command to execute, it determines $?. In this
case, the `echo' succeeded (it only fails on write errors).
> Is assigning $(false) to a variable first the only option?
Yes. Letting the command substitution determine the exit status of an
assignment is the special case.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/