[Top][All Lists]

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

Re: in-line calls to functions cause "exit" in the function to act like

From: Chet Ramey
Subject: Re: in-line calls to functions cause "exit" in the function to act like "return"
Date: Sun, 19 Dec 2021 13:15:12 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1

On 12/18/21 8:07 AM, yesxorno via Bug reports for the GNU Bourne Again SHell wrote:

> When 'exit' is executed in a function called to "in-line" its output to > stdout, the 'exit' acts like return, leaving the function scope, but not > terminating the bash process.

I assume by "in-line" you mean command substitution.

The bash documentation says this about command substitution:

"Bash performs the expansion by executing command in a subshell environ-
ment and replacing the command substitution with the standard output of
the command, with any trailing newlines deleted."

The documentation describes a subshell environment more completely, but
the important piece is that the shell forks and creates a subshell. That
subshell is what the `exit' acts on.

``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/

reply via email to

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