bug-bash
[Top][All Lists]
Advanced

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

Re: Incorrect alias expansion within command substitution


From: Chet Ramey
Subject: Re: Incorrect alias expansion within command substitution
Date: Tue, 1 Feb 2022 10:50:37 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.4.1

On 2/1/22 10:23 AM, Chet Ramey wrote:

If you defer alias expansion until execution, you lose the (posix-
encouraged but officially unspecified according to the approved
interpretation of issue 1342) ability to have aliases affect command
parsing in the command substitution:

Well, I went back and read the entire interpretation. The part that's not
specified is whether an alias expansion provides the closing `)', but alias
expansion has to be performed while parsing the contents of the command
substitution:

"existing aliases are required to be expanded when the shell parses the
input that follows the "$(" in order to find the terminating ')'"

and (in the same interpretation):

"Historically some shells used simple parenthesis counting to find the
terminating ')' and therefore did not account for aliases. However, such
shells never conformed to POSIX, which has always required recursive
parsing (see XCU 2.3 item 5)."

So this seems like behavior that should be conditional on posix mode to
preserve backwards compatibility.

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