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: Lawrence Velázquez
Subject: Re: for loop over parameter expansion of array can miss resulted empty list
Date: Tue, 22 Mar 2022 23:31:46 -0400
User-agent: Cyrus-JMAP/3.5.0-alpha0-4907-g25ce6f34a9-fm-20220311.001-g25ce6f34

On Tue, Mar 22, 2022, at 11:05 PM, L A Walsh wrote:
> On 2022/03/22 14:04, Lawrence Velázquez wrote:
>> On Tue, Mar 22, 2022, at 4:53 PM, L A Walsh wrote:
>>   
>>> On 2022/03/21 03:40, Alex fxmbsw7 Ratchev wrote:
>>>     
>>>> i solve this by shopt -s nullglob
>>>>   
>>>>       
>>>>> Repeat-By:
>>>>>    Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done
>>>>>    Result: none
>>>>>    Expected result: i is ''
>>>>>     
>>>>>         
>>> if you have nullglob set, then that is not the correct result.
>>>     
>>
>> The original bug report said nothing about nullglob.
>>   
> ----
> Sorry, I got sidetracked.  In this case it wouldn't matter,
> if you have no directories where you are running this,
> then nothing will match, and it
> will be a null (empty) expression.

The contents of the current working directory don't come into play,
as the original test case does not perform any filename generation.
Note that nearly everything there is quoted.

> Sorry for my getting sidetracked (it happens alot.

No worries.

-- 
vq



reply via email to

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