Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15240 > unrolled thread

Re: errata: Explicit variables declaration statements do not resolve back-references from same statement

Started byChet Ramey <chet.ramey@case.edu>
First post2019-07-24 15:34 -0400
Last post2019-07-24 15:34 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: errata: Explicit variables declaration statements do not resolve back-references from same statement Chet Ramey <chet.ramey@case.edu> - 2019-07-24 15:34 -0400

#15240 — Re: errata: Explicit variables declaration statements do not resolve back-references from same statement

FromChet Ramey <chet.ramey@case.edu>
Date2019-07-24 15:34 -0400
SubjectRe: errata: Explicit variables declaration statements do not resolve back-references from same statement
Message-ID<mailman.2170.1563996886.2688.bug-bash@gnu.org>

[Multipart message — attachments visible in raw view] — view raw

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/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web