From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: tilde syntax
Date: Fri, 5 Jan 2024 08:42:32 -0800 [thread overview]
Message-ID: <b0cfe3f6-27aa-416f-9ac4-db0cc7012a28@eastlink.ca> (raw)
In-Reply-To: <CAA=-s3yuJ6_5Y9+NEXO00NE-k896-D6c9p-KtDquzWrg-Xx9_g@mail.gmail.com>
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.
next prev parent reply other threads:[~2024-01-05 16:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 22:31 Ray Andrews
2024-01-04 22:49 ` Bart Schaefer
2024-01-04 23:04 ` Ray Andrews
2024-01-04 23:40 ` Lawrence Velázquez
2024-01-05 0:12 ` Ray Andrews
2024-01-05 1:41 ` Lawrence Velázquez
2024-01-05 2:03 ` Ray Andrews
2024-01-05 14:41 ` Mark J. Reed
2024-01-05 16:42 ` Ray Andrews [this message]
2024-01-05 19:58 ` Bart Schaefer
2024-01-05 22:50 ` Ray Andrews
2024-01-05 23:27 ` Bart Schaefer
2024-01-05 23:47 ` Ray Andrews
2024-01-06 0:23 ` Bart Schaefer
2024-01-06 3:44 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b0cfe3f6-27aa-416f-9ac4-db0cc7012a28@eastlink.ca \
--to=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).