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


Groups > gnu.bash.bug > #16620

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

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Lawrence Velázquez <vq@larryv.me>
Newsgroups gnu.bash.bug
Subject Re: No word splitting for assignment-like expressions in compound assignment
Date Mon, 27 Jul 2020 03:06:22 -0400
Lines 60
Approved bug-bash@gnu.org
Message-ID <mailman.129.1595833589.2739.bug-bash@gnu.org> (permalink)
References <87o8o1zfpn.fsf@hobgoblin.ariadne.com> <F420E583-E5D4-48BB-98E3-044C700BA07A@larryv.me>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0 (Mac OS X Mail 12.4 \(3445.104.14\))
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1595833590 4483 209.51.188.17 (27 Jul 2020 07:06:30 GMT)
X-Complaints-To action@cs.stanford.edu
Cc Alexey Izbyshev <izbyshev@ispras.ru>, bug-bash@gnu.org
To "Dale R. Worley" <worley@alum.mit.edu>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=larryv.me; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=Z j9dxnzAV9+Re/CxCr2VTrqk4wt5qhgsvq+hOwxnXaU=; b=RKf2Adwj1lZW9ulKL uhJlXHsR65W69erXlix1/vWWhUL1GttifwX5RT1O19BN0qmt4chJCxnHCF6bAxBM MNuGEa3cCPXH+Hwo0UvdU/qUD8cdJXZ7BhTQCMJWvPmRtRq28ZiE1Q/ntAGjPlRR McPpfwEYMuWcH03iXV0yhMGA3+1HqVFTAVUMxtHIitNtlxrhavxAVVBetnO+RKgo Nh1LPZPoHw0NMpvRZvFI6cAlcGZ8R9OaAAKCiwmepWe5XSiNu5lH3U03Cl82C4I2 PNkGDS09l4HOtbtZ9YP/tyqB3l9GWZoOtd3CAmVo2cLwbudZROAjt5TyxJUlVCus 8U8BQ==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=Zj9dxnzAV9+Re/CxCr2VTrqk4wt5qhgsvq+hOwxnX aU=; b=ki6VLOBmqKbgew3OdZyE9e8WrO9VDsb6yDZvXIscsCaoY4kMZK2Hgl74W iAKBw3m//GCPg7oNiGw7Z51WEAlE5L/NH2IfCOsR3h/cItSuv2uvhI2tbKUky229 iy/AVV95y4MF0LcKs/bLkCtCV+6QVyMVtowhw1vec3aUy6jviR4Sm947kPi45r7r z0p5Oo0bdR/IP+Ut81XSx3louxNdfZn0dKqUQUiaGgpcqleTbd3CFAx+rrkITpE2 DE9BDfQWQZPR+crHEtKxeeqyEOxv891+9ayP8kpqVf/q1f5faUWEMv1VlAnmemMU chhQ2TVyBRLgK/C2MMdXpJtqnjXKA==
X-ME-Sender <xms:73weX4OpyKKHZp8L1_K084z4-kXwDoEYLfRHDoLEQQ6gMNoYM34n-A>
X-ME-Proxy-Cause gggruggvucftvghtrhhoucdtuddrgeduiedrheelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpegtggfuhfgjfffgkfhfvffosehtqhhmtdhhtddvnecuhfhrohhmpefnrgifrhgv nhgtvggpgggvlhojiihquhgviicuoehvqheslhgrrhhrhihvrdhmvgeqnecuggftrfgrth htvghrnhepgeetheejueekgeffhefhjeevjeeiheegvdeugeektdegffejhfehgeetgfej ledvnecukfhppedutddtrdduvddrudejkedrvdefnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepvhhqsehlrghrrhihvhdrmhgv
X-ME-Proxy <xmx:73weX-_6db60J8ZxHvSleBhNQE5rfaQGT67KO6tYbRMxUDwc4qMsPA> <xmx:73weX_TpYqVKczjBv44b1aytBgk9QtJcH-mEr8RqNt_gqzVlmkReSg> <xmx:73weXwtBItO44XWnATCnr-2-y2Qd_F9J0bsdu-ASEVUp75avZhTAHw> <xmx:8HweX6r8XvmCjgsdcoCK-p1KTkL5ZWuGk25eL3yEle9m_KavGQdWUg>
In-Reply-To <87o8o1zfpn.fsf@hobgoblin.ariadne.com>
X-Mailer Apple Mail (2.3445.104.14)
Received-SPF pass client-ip=66.111.4.25; envelope-from=vq@larryv.me; helo=out1-smtp.messagingengine.com
X-detected-operating-system by eggs.gnu.org: First seen = 2020/07/27 03:06:24
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int -27
X-Spam_score -2.8
X-Spam_bar --
X-Spam_report (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <F420E583-E5D4-48BB-98E3-044C700BA07A@larryv.me>
X-Mailman-Original-References <87o8o1zfpn.fsf@hobgoblin.ariadne.com>
Xref csiph.com gnu.bash.bug:16620

Show key headers only | View raw


> On Jul 27, 2020, at 1:31 AM, Dale R. Worley <worley@alum.mit.edu> wrote:
> 
> 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.


If word splitting were not performed in compound assignments, this...

    foo=(a b c)

...would not work. If pathname expansion were not performed in compound
assignments, this...

    foo=(*)

...would not work. Arrays would become significantly less usable if
word splitting and pathname expansion were not allowed in compound
assignments.

vq

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


Thread

Re: No word splitting for assignment-like expressions in compound assignment Lawrence Velázquez <vq@larryv.me> - 2020-07-27 03:06 -0400

csiph-web