help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Doc on simple command expansion


From: Glen Huang
Subject: Doc on simple command expansion
Date: Thu, 3 Mar 2022 19:11:51 +0800

Hi,

I'm having difficulty understanding this paragraph from Bash Reference
Manual Chapter 3.7.1.

> If one of the expansions contained a command substitution, the exit status of 
> the command
> is the exit status of the last command substitution performed. If there were 
> no command
> substitutions, the command exits with a status of zero.

Which seems to indicate that for a simple command like this

echo "$(false)"

echo's return status should be determined by that of false, which is
apparently not the case. So I wonder what scenario this paragraph is
describing?

Also I'm trying to locate the definitive description on what should
happen for the previous command under "set -e". I guessed that false
should make the script exit before echo could have a chance printing
anything, but from my testing on bash 5.1.16, it's not the case: echo
would print an empty string and the script was finished with a status
0.

Why set -e wouldn't work in this case? Any way to make it behave as I intend?

Would be grateful if anyone could shed some light.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]