[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: looping over variables & exporting them at the same time ?
From: |
Zachary Santer |
Subject: |
Re: looping over variables & exporting them at the same time ? |
Date: |
Mon, 29 Jan 2024 11:43:50 -0500 |
On Mon, Jan 29, 2024 at 7:29 AM Greg Wooledge <greg@wooledge.org> wrote:
> The second form does word splitting using the default IFS, so you would
> want to change that. This leaves IFS in an altered state (you can't
> temporarily assign it for this command only, because it's an assignment),
> unless the assignment is done inside a function where IFS is local.
>
If OP is really just handling lists of whitespace-delimited words in string
variables, the default IFS should be fine.
It also does globbing (filename expansion), which you would need to
> suppress.
I didn't know that.
Once again, this leaves the shell in an altered state, unless
> you use "local -" inside a function to localize the -f/+f setting.
> That in turn would bump up the required bash version to 4.4.
>
I set -o noglob/-f in any script where I don't use pathname expansion, i.e.
basically all of them. Lots of potential surprises, evidently. I shouldn't
assume everyone else is going to do the same, though.
- Re: looping over variables & exporting them at the same time ?, (continued)
- Re: looping over variables & exporting them at the same time ?, Greg Wooledge, 2024/01/28
- Re: looping over variables & exporting them at the same time ?, Zachary Santer, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, Greg Wooledge, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, alex xmb sw ratchev, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, Paxsali, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, Paxsali, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, Greg Wooledge, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, Paxsali, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, Greg Wooledge, 2024/01/29
- Re: looping over variables & exporting them at the same time ?, Zachary Santer, 2024/01/29
- Re: looping over variables & exporting them at the same time ?,
Zachary Santer <=