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

Re: tilde syntax



On Fri, Jan 5, 2024 at 8:42 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> So one might say that by default a variable expands with implicit single
> quotes around it?

Approximately so, yes.  Not precisely so in the case of nested expansions.

> But the tilde reverts it to 'unquoted' (for lack of a
> better word)?

Only with respect to pattern characters, but yes.

> And this was a design choice at
> variance with shell tradition, so obviously very deliberately chosen?

It was in fact one of the primary reasons for the creation of zsh in
the first place, to make the behavior of parameter expansions more
consistent without always having to use double quotes around them.

> So the only alternative would be if the tilde worked in
> reverse -- presume expandable but force literal

  setopt glob_subst
  print -- ${~~asterisk}
does exactly that.




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