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

Re: Forcing expansion without explicit eval nor a subshell?



    Hi Lloyd ;)))))


 * Lloyd Zusman <ljz@xxxxxxxxxx> dixit:
> Suppose I have the following variable defined:
> 
>   yumargs='--disablerepo=livna{,-updates,-testing,-extras}'
> 
> I know that I can do this:
> 
>   eval yum ${yumargs} update
> 
> And this:
> 
>   yum $(eval print -- ${yumargs}) update
[...] 
> However, I'm wondering if there is a way to get the same effect without
> explicitly using "eval" and without invoking a subshell via the $()
> construct (nor with its moral equivalent, ``).

    Well, I'm by no means an expert, but as far as I know, Zsh does
parameter expansion *first* and brace expansion *last* in the same
step. As zsh does not reparse and rexpand, you need to first expand
the parameter and after that expand the braces. That's why you need
the eval.

> By the way, I tried the (e) operator within the ${} construct, but that
> didn't work for me.

    Of course, because (e) doesn't perform brace expansion ;)

    Sorry for not being much helpful O:) I'm sure that somebody here
can think of a solution without using "eval" (although that's why
eval exists...).

    Buena suerte, Lloyd, y encantado de hablar otra vez contigo :)
(Good luck, Lloyd, and pleased to talk with you again):

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...



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