Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: tilde syntax
On 2024-01-05 06:41, Mark J. Reed wrote:
Running this:
asterisk='*'
echo $asterisk
echo $~asterisk
echo '*'
echo *
... gives me:
*
1 2 3 4 5
*
1 2 3 4 5
So one might say that by default a variable expands with implicit single
quotes around it? But the tilde reverts it to 'unquoted' (for lack of a
better word)? So in my original, " zsh_case='(#i)' " what I was doing,
without the tilde, is sending " (#i) " not as an expansion directive,
but as a literal string? Yeah, where I crashed and burned was not
seeing that " (#i) " and " * " are subject to the same rule -- both are
presumed to be directives but both can also be literal, and when used
via a variable, they are literal. Yes? And this was a design choice at
variance with shell tradition, so obviously very deliberately chosen?
Well then, counter intuitive as it is, I'll take it on faith that this
is the better design. Subject to further correction: by George, I
think I've got it.
Besides: " echo '$asterisk' " obviously won't do what I might have been
aiming at. So the only alternative would be if the tilde worked in
reverse -- presume expandable but force literal -- and that's merely
another design choice -- six of one half a dozen of the other -- so we
have what the devs considered the most convenient :-) This will fit
several more pieces into the puzzle, not just one. zsh is full of these
invisible differences: is that a directive or is it text? Sometimes the
presumption is one, sometimes the other. This helps me see the
invisible difference.
Thank you Sensei.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author