[Top][All Lists]

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

Re: errata: Explicit variables declaration statements do not resolve bac

From: Chet Ramey
Subject: Re: errata: Explicit variables declaration statements do not resolve back-references from same statement
Date: Wed, 24 Jul 2019 15:34:26 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

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    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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