thank you Peter, I made a mistake in the example code: file="filename.txt" a="*$file*" should have been: file="filename.txt" a='*$file*' with single quotes the behaviour is changed: zsh -fc 'file= filename.txt; a="*$file*"; print "$a"' gives: *filename.txt* instead with single quotes: zsh -fc 'file= filename.txt; a=''*$file*''; print "$a"' gives *$file* I would like the second example to somehow give the result of the first, since I am trying to pass the string from another context where the variable $file is not already defined thanks Pier Paolo Grassi linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217 founder: https://www.meetup.com/it-IT/Machine-Learning-TO Il giorno mar 30 lug 2019 alle ore 15:19 Peter Stephenson < p.stephenson@samsung.com> ha scritto: > 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 > >