From: Lloyd Zusman <ljz@asfast.com>
To: zsh-users@sunsite.dk
Subject: Re: Forcing expansion without explicit eval nor a subshell?
Date: Sat, 05 Nov 2005 22:40:53 -0500 [thread overview]
Message-ID: <m3acgimoje.fsf@asfast.com> (raw)
In-Reply-To: <1051106030216.ZM25909@candle.brasslantern.com>
Bart Schaefer <schaefer@brasslantern.com> 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@asfast.com
God bless you.
prev parent reply other threads:[~2005-11-06 3:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-05 4:01 Lloyd Zusman
2005-11-05 8:45 ` DervishD
2005-11-05 19:56 ` Bart Schaefer
2005-11-05 20:03 ` Lloyd Zusman
2005-11-05 21:33 ` Bart Schaefer
2005-11-05 22:07 ` Lloyd Zusman
2005-11-05 22:44 ` OT: poldek [Re: Forcing expansion without explicit eval nor a subshell?] GoTaR
2005-11-06 3:02 ` Forcing expansion without explicit eval nor a subshell? Bart Schaefer
2005-11-06 3:40 ` Lloyd Zusman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3acgimoje.fsf@asfast.com \
--to=ljz@asfast.com \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).