help-bash
[Top][All Lists]
Advanced

[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: Sun, 28 Jan 2024 23:43:49 -0500

On Sun, Jan 28, 2024 at 11:07 PM Greg Wooledge <greg@wooledge.org> wrote:

> While this does work, I still prefer treating a list as a real list,
> and expanding it out into an array for whatever operations are desired.
> If the problem evolves, and the desired operations become more complex --
> or if the problem statement we've been given is not complete -- then
> having the list items in separate array elements will be an advantage.
>

I'm curious if the guy's actual use-case is even really a list, or if
that's being extrapolated out of the example he made of what he wanted to
be able to do. If these things are lists, they should live and die as
arrays, but then you can't export them.

If I could critique your solution a little,

Why do
IFS=' ' read -ra list <<< "${!v}"
instead of
list=( ${!v} )
?

And nameref variables could simplify what you're doing as well.


reply via email to

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