On 7/24/19 2:06 PM, Léa Gris wrote:
> Found this strange behavior difference in Bash, between explicit and
> implicit declarations of variables.

It's not that strange.

> An implicit variables declaration statement resolve back-references to
> variables from the same statement.

An assignment statement.

> 
> Whereas:
> 
> An explicit variables declaration statement does not resolve back-reference
> variables from the same statement.

A builtin command performing an assignment on its arguments.

Look at it this way. Since builtins are simple commands, their arguments
are expanded before being invoked. The job of the builtin is to take the
expanded arguments and perform the assignments (values and attributes).
Since the expansions are performed before the builtin is invoked, the
values have not been updated by any previous assignments appearing as
arguments to the builtin.


> ksh93 resolves explicit back-references with typeset.

ksh93 probably does something special to the arguments to typeset so
they're different from other builtins. Bash does some similar things
to implement POSIX's concept of `declaration commands', but those have
mostly to do with the expansions performed on the rhs of the assignment.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to