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


Groups > gnu.bash.bug > #16619

Re: No word splitting for assignment-like expressions in compound assignment

From worley@alum.mit.edu (Dale R. Worley)
Newsgroups gnu.bash.bug
Subject Re: No word splitting for assignment-like expressions in compound assignment
Date 2020-07-27 01:31 -0400
Message-ID <mailman.124.1595813515.2739.bug-bash@gnu.org> (permalink)
References <6614fa7668daf7f2b450e319a28b624c@ispras.ru> <87o8o1zfpn.fsf@hobgoblin.ariadne.com>

Show all headers | View raw


Alexey Izbyshev <izbyshev@ispras.ru> writes:
> I have a question about the following behavior:
>
> $ Z='a b'
> $ A=(X=$Z)
> $ declare -p A
> declare -a A=([0]="X=a b")
> $ A=(X$Z)
> $ declare -p A
> declare -a A=([0]="Xa" [1]="b")
>
> I find it surprising that no word splitting is performed in the first 
> compound assignment.

> * Brace expansion is performed for "A=(X=a{x,y}b)" by all bash versions 
> mentioned above (which is inconsistent with normal variable assignment).
> * Globbing for "A=(X=a?b)" is performed by bash 3.1.17, but not by other 
> versions.

Interesting.  The documentation for 4.2.53(1) says this about parameter
assignments generally, with no special rules for compound assignments:

       All
       values undergo tilde expansion, parameter and variable expansion,  com-
       mand  substitution, arithmetic expansion, and quote removal (see EXPAN-
       SION below).  ...  Word  splitting  is  not
       performed,  with the exception of "$@" as explained below under Special
       Parameters.  Pathname expansion is not  performed.

So it seems like the word splitting in "A=(X$Z)" is incorrect.  So is
pathname expansion in that context.  Oddly, brace expansion is not
mentioned.

Dale

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: No word splitting for assignment-like expressions in compound assignment worley@alum.mit.edu (Dale R. Worley) - 2020-07-27 01:31 -0400

csiph-web