[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: |
Greg Wooledge |
Subject: |
Re: for loop over parameter expansion of array can miss resulted empty list |
Date: |
Mon, 21 Mar 2022 07:37:22 -0400 |
Stop. Posting. Upside-down.
> > On Sun, Mar 20, 2022, 22:07 Alexey via Bug reports for the GNU Bourne
> > > Repeat-By:
> > > Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done
> > > Result: none
> > > Expected result: i is ''
> On 2022-03-21 14:40, Alex fxmbsw7 Ratchev wrote:
> > i solve this by shopt -s nullglob
On Mon, Mar 21, 2022 at 02:51:14PM +0400, Alexey via Bug reports for the GNU
Bourne Again SHell wrote:
> nullglob is not applicable in this situation, because no 'Pathname
> Expansion' is occur.
I can confirm that Alexey's example produces the unexpected result
on my system (bash 5.1), and that "shopt -s nullglob" has no effect
on it.
unicorn:~$ bash
unicorn:~$ x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done
unicorn:~$ shopt -s nullglob
unicorn:~$ x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done
unicorn:~$
Re: for loop over parameter expansion of array can miss resulted empty list, L A Walsh, 2022/03/22
Re: for loop over parameter expansion of array can miss resulted empty list, L A Walsh, 2022/03/22
Re: for loop over parameter expansion of array can miss resulted empty list, Chet Ramey, 2022/03/24