bug-bash
[Top][All Lists]
Advanced

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

Re: splitting/whitespace in expansions of ${*} vs ${*/}


From: Chet Ramey
Subject: Re: splitting/whitespace in expansions of ${*} vs ${*/}
Date: Sat, 1 Apr 2017 21:05:06 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 3/30/17 4:30 AM, Grisha Levit wrote:
> Sorry if you already noticed this: The latest devel push fixes the reported
> field-splitting case but there is a regression with the fields getting
> re-joined with spaces when performing an assignment:
> 
>    $ set -- 1 2; IFS=; a=$* b=${*/}; printf '<%s>' "$a" "$b"
>    <12><1 2>
> 
> and with the expansion producing fields in the PE assignment case:
> 
>    $ set -- 1 2; IFS=; unset a b; printf '<%s>' ${a=$*} ${b=${*/}}
>    <12><1><2>

Thanks for the report.  This will be fixed in the next devel branch push.

> Also, upon closer inspection, I suspect the unset IFS case in my report is
> actually an issue with the a=$* case and that b=${*/} behaves correctly
> (aside from not matching the a=$* behavior).  The whitespace-trimming-when-
> not-field-splitting thing is something that changed in bash-4.3:
> 
>    bash-4.2$ unset IFS; set ' '; a=$*; printf '<%s>' "$a"
>    < >
>    bash-4.3$ unset IFS; set ' '; a=$*; printf '<%s>' "$a"
>    <>

This, too, but we're getting into more and more corner cases here, as
evidenced by the fact that this hasn't been reported until now.

> 
> Also also, the field-splitting issue is also present for arrays subscripted
> with * when undergoing case modification or pattern substitution:
> 
>    $ A=(1 2); IFS=; printf '<%s>' ${A[*]} ${A[*]/}
>    <1><2><12>

That's next to look at. I haven't made analogous changes to the array
expansion code yet.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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