Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Forcing expansion without explicit eval nor a subshell?



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:

> On Nov 5,  3:03pm, Lloyd Zusman wrote:
> }
> } I want to defer it in case I do this:
> } 
> }   yumargs='--disablerepo={dag,$livnastuff}'
> } 
> } ... where $livnastuff can change, and where it might or might not
> } involve more brace expansions.
>
> The answer is still to stop thinking about brace expansions and start
> thinking about array expansions.
>
>     yumargs=( --disablerepo={dag,'$^livnastuff'} )
>     livnastuff=( dries extras )
>     yum ${(e)yumargs}
>
> You can keep abstracting this out:
>
>     reponames=( dag '$^livnastuff' )
>     yumargs=( --disablerepo=$^reponames )
>     livnastuff=( dries extras )
>     yum ${(e)yumargs}
>
> Or
>
>     pkgnames=( kernel '$^livnapkgs' )
>     reponames=( dag '$^livnarepos' )
>     yumargs=( --exclude='${(e)^pkgnames}' --disablerepo='${(e)^reponames}' )
>     livnarepos=( dries extras )
>     yum ${(e)yumargs}


Hmm ... OK.  I get it.  Thanks.

However, I'm still not sure how to do what I want in the array world,
because sometimes, there is nesting.

I'll explain:

This is what I often need to do these days, because the livna sites seem
to be down a lot:

  yum --disablerepo=livna \
      --disablerepo=livna-updates \
      --disablerepo=livna-extras \
      --disablerepo=livna-testing \
      update

This could be abreviated as such, in the brace-expansion world:

  yum --disablerepo=livna{,-updates,-extras,-testing} update

But sometimes, I also want to disable others, which would go like this:

  yum --disablerepo={dag,livna{,-updates,-extras,-testing}} update

Note the nesting of braces in this case.

Other times, livna is OK, but freshrpms is down:

  yum --disablerepo={dag,freshrpms} update

Therefore, sometimes there is nesting, and other times, there isn't.

I can't figure out how to do the nesting stuff using arrays, without
things getting rather complex.  The brace syntax handles nesting very
nicely.

But perhaps I'm still missing something about arrays ... ???


-- 
 Lloyd Zusman
 ljz@xxxxxxxxxx
 God bless you.



Messages sorted by: Reverse Date, Date, Thread, Author