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

Re: Forcing expansion without explicit eval nor a subshell?



On Nov 4, 11:01pm, Lloyd Zusman wrote:
} Subject: Forcing expansion without explicit eval nor a subshell?
}
} Suppose I have the following variable defined:
} 
}   yumargs='--disablerepo=livna{,-updates,-testing,-extras}'
} 
} I want to assign to "yumargs" exactly as I did above, if possible, and
} I'm looking for some combination of modifiers within the ${} construct
} which would give me the expansion of "yumargs" that I desire, and
} without the need for a subshell.  And I'd like the expansion of
} "yumargs" to take place at the time it is used in the "yum" command, not
} at the time that I define it.
} 
} Is all this possible?  If so, could someone give me a hint or pointer?

Given all the restrictions you've placed, no, it's not possible.  There
is no parameter-expansion modifier to force brace expansion.

If you relax the "exactly as above" restriction, you could do this:

yumargs=( --disablerepo=livna{,-updates,-testing,-extras} )

That is, make yumargs be an array of four strings rather than a single
string that contains a brace expression.  I'm unable to see a reason why
it would matter when the brace expansion is performed; but if you think
it's important to defer it, you're going to be stuck with eval.



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