bug-bash
[Top][All Lists]
Advanced

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

Re: ="${@:...}" and ="${@/...}" join with IFS since after 4.4


From: Chet Ramey
Subject: Re: ="${@:...}" and ="${@/...}" join with IFS since after 4.4
Date: Mon, 17 Nov 2025 16:28:56 -0500
User-agent: Mozilla Thunderbird

On 11/15/25 7:42 PM, Emanuele Torre wrote:
On Sun, Nov 16, 2025 at 01:23:35AM +0100, Emanuele Torre wrote:
Normally "$@"/"${arr[@]}" on the RHS side of an assignment joins the
elements with ' ' even if IFS is set to a string with a first character
that is not space.

It has been pointed out to me that ${@#?} (and likewise %%.. %.. ##..)
also always uses IFS in this context, similarly to ${@@Q}:

     bash-5.3$ set aa bb cc; IFS=: o=${@#?}; declare -p o
     declare -- o="a:b:c"
     bash-5.3$ set aa bb cc; IFS=: o="${@#?}"; declare -p o
     declare -- o="a:b:c"

This is easy enough to fix; the pattern expansion operators didn't know
the expansion was taking place on the rhs of an assignment statement.

--
``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: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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