help-bash
[Top][All Lists]
Advanced

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

Re: quote interpretation via vars without eval


From: Chet Ramey
Subject: Re: quote interpretation via vars without eval
Date: Sat, 13 Mar 2021 11:53:10 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

On 3/13/21 6:35 AM, Koichi Murase wrote:
2021年3月13日(土) 7:59 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>:
i was doing declare -p to again modifications, and noticed i can include
quotes inside the declare settment ( declare [-opts] "$res" )
where else do the quotes get interpreted, can you write a short list ?

`declare' is a command that takes string arguments [but with an
exception for the array assignments of the form `arr=(...)']. You can
quote them since they are treated as normal arguments.

Not exactly. Builtins like `declare' and `local' (and `export' and
`readonly') that accept assignment statements are so-called "declaration
commands."

If the shell can recognize the argument to a declaration command as an
assignment statement while parsing, it's subjected to the same
expansions as an assignment statement. In particular, that means pathname
expansion and word splitting are not performed.

POSIX approved an interpretation concerning "declaration utilities" back in
2011, and it will be a part of the upcoming issue 8.

https://www.austingroupbugs.net/view.php?id=351

Bash-4.0 and later versions attempt to expand assignment statement
arguments to declaration commands the same way as standalone assignment
statements.

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