bug-bash
[Top][All Lists]
Advanced

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

Re: for loop over parameter expansion of array can miss resulted empty l


From: Chet Ramey
Subject: Re: for loop over parameter expansion of array can miss resulted empty list
Date: Thu, 24 Mar 2022 10:16:32 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

On 3/20/22 5:05 PM, Alexey via Bug reports for the GNU Bourne Again SHell wrote:

Bash Version: 5.1
Patch Level: 16
Release Status: release

Description:
  If use 'Parameter Expansion', for example 'Remove matching suffix pattern', on array and try to iterate over expansion result with for loop, may occur that loop body will not be executed at all.

Repeat-By:
   Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done
   Result: none
   Expected result: i is ''

Thanks for the report. This is the same issue as

https://lists.gnu.org/archive/html/bug-bash/2022-03/msg00033.html

It will be fixed in the next release.

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://tiswww.cwru.edu/~chet/



reply via email to

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