help-bash
[Top][All Lists]
Advanced

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

Re: expand existing file system entries in one declare


From: alex xmb ratchev
Subject: Re: expand existing file system entries in one declare
Date: Sat, 4 Mar 2023 17:43:26 +0100

On Sat, Mar 4, 2023, 5:21 PM Greg Wooledge <greg@wooledge.org> wrote:

> On Sat, Mar 04, 2023 at 11:02:56AM +0100, alex xmb ratchev wrote:
> >  in array= (
> > @(){<list,list>}
> >  ) # the entries are @Q escaped
>
> That isn't the correct syntax for an extended glob which expands to
> either of two patterns.  You want this instead:
>

i agree , mate
as i realise just now , the function of @(..) is actually expanding file
system elements

array=(
>     @(list|list)
> )
>

so ye next time ill use this
in a declare -A string
cause how else to expand @(user_entries) , than have to parse it the bash
way , that declare does too

>  ) # the entries are @Q escaped
>
> What does that mean?


@Q in var expand , for use in flat strings

>
> > i couldnt make ${*:2@Q} work
>
> What is that even trying to do?  Create a new pseudo-list encased in a
> string which can be used by 'eval'?  If so... WHY?!
>

its not for eval , .. its to expand this way but inside declare instead of
eval
less eval
and the user entries will look like
@('entry'|'second')
the quotes done by @Q
their and @( .. ) parsing the done by declare , not eval

i ripped eval much , but declare does a real good job at it

If you just want "all except the first", it would be so much clearner to
> store them in an array:
>
> therest=( "${@:2}" )
>

i did at some point
but my point is less var copy stuff for static stuff , just partly i do so

Or, simply use "shift" if you no longer need "$1" any longer.
>

i did in the end use shift 1 , whereever that was

greetings mate ..

>


reply via email to

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