Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Forcing expansion without explicit eval nor a subshell?
- X-seq: zsh-users 9650
- From: Lloyd Zusman <ljz@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Forcing expansion without explicit eval nor a subshell?
- Date: Sat, 05 Nov 2005 22:40:53 -0500
- Cancel-lock: sha1:GKKShDiITXtFtR3V6tMZkcsVWEE=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <m364r73fpp.fsf@xxxxxxxxxx> <1051105195640.ZM24493@xxxxxxxxxxxxxxxxxxxxxxx> <m3d5lezwu7.fsf@xxxxxxxxxx> <1051105213315.ZM24679@xxxxxxxxxxxxxxxxxxxxxxx> <m33bmaycil.fsf@xxxxxxxxxx> <1051106030216.ZM25909@xxxxxxxxxxxxxxxxxxxxxxx>
- Sender: news <news@xxxxxxxxxxxxx>
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:
> On Nov 5, 5:07pm, Lloyd Zusman wrote:
> }
> } I can't figure out how to do the nesting stuff using arrays, without
> } things getting rather complex.
>
> You do end up needing one array for each level of nesting.
>
> E.g.:
>
> yumargs=( --disablerepo='${(e)^disablerepos}' )
> disablerepos=( dag '${(e)^livnarepos' )
> livnarepos=( livna{,-updates,-extras,-testing} )
>
> yum ${(e)yumargs}
>
> This corresponds to your example
>
> yum --disablerepo={dag,livna{,-updates,-extras,-testing}}
>
> The extra arrays are the price you pay for wanting to avoid defining
> e.g. $livnarepos until the last minute and also avoid eval.
>
> You might also ask yourself whether there's another way to get the end
> result that you want, such as writing a wrapper function around yum.
Thanks.
Well, after realizing that I have to use "eval" with brace expansion, I
went and wrote this wrapper function:
function yum {
eval /usr/bin/yum ${yumargs:-} '"$@"'
}
... and I have these variables set:
livna='livna{,-testing,-updates,-extras}'
dag=dag
dries=dries
freshrpms=freshrpms
newrpms=newrpms
fedora='fedora-{core,extras}'
Then, I can do things like this:
yumargs="--d={$dag,$livna}" # --d is equivalent to --disablerepo
yum update
This lets me change yumargs based on the availability of the
repositories, and then just issue normal "yum" commands.
And now I see how I can do pretty much the same thing with arrays.
Thanks again.
--
Lloyd Zusman
ljz@xxxxxxxxxx
God bless you.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author