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

Re: variable expansion inside string



On Tue, 2019-07-30 at 14:28 +0200, Pier Paolo Grassi wrote:
> Hello, is it possibile to do only variable expansion inside a string, eg:
> 
> file="filename.txt"
> a="*$file*"

If you run zsh -f, you'll see that that's exactly what you normally get, just
by running

print "$a"

--- no eval.

My best guess is you have the option globsubst set and when you tried
to print the result, you didn't use double quotes at that point, i.e.
you had something like

print $a

and the *filename.text* got expanded at that point.

So the original code is actually fine.

pws



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