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

Re: Expanding a variable extracted from another file



On Sat, May 16, 2020 at 12:14 AM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> What is the meaning of quotes? Are these all equivalent?
>
>   "$HOME/foo/bar"
>   '$HOME/foo/bar'
>   $HOME/foo/bar
>   \$HOME/foo/bar
>
> Code posted by Bart assumes that they are. ${(Qe)MYVAR} have the same
> value if MYVAR is set to any of these lines.

You're correct about Q but only the one with a backslash seems to make
any difference to ${(e)...}:

% print -rl -- $quotings
"$HOME/foo/bar"
'$HOME/foo/bar'
$HOME/foo/bar
\$HOME/foo/bar
$'$HOME/foo/bar'
% print -rl -- ${(e)quotings}
"/Users/schaefer/foo/bar"
'/Users/schaefer/foo/bar'
/Users/schaefer/foo/bar
$HOME/foo/bar
$'/Users/schaefer/foo/bar'
%

Compare this, which is I'm sure what you were thinking of:

% eval print -rl -- $quotings
/Users/schaefer/foo/bar
$HOME/foo/bar
/Users/schaefer/foo/bar
$HOME/foo/bar
$HOME/foo/bar
%



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