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

Re: convolutions

On 11/06/2015 10:38 PM, Mikael Magnusson wrote:
No, because 'expanding into "\e"' means nothing useful, did you mean a
literal backslash followed by an e, or a literal escape?

It's not arguable sir. If you found it vague, then you found it vague, but to me:

     " \e[31;1m "

... is very obviously a color code which I hold in my variable " ${red} " and I want to expand it inside a file.

If you store the string in a parameter and echo that parameter, the color variables also don't expand.
So you have a file with "${red}" in it, and you want to read in the
file, and substitute the value of any parameter references.

these parameters are not defined in the file, but are set in the shell
environment and you happen to know that they are string
representations of color escape sequences, and you want to expand
these as well.

Of course. Who but me knows what's in my environment variables?
If your file has a semicolon in it somewhere, then your command will
run arbitrary code. Bart's example doesn't have that exact problem,
but will still execute code if there are things like $(command) in the

Yes, I know how dangerous eval is, that's why I'm asking for a better idea--some way of expanding parameters inside a file. Not just color variables really, any variables.

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