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

Re: tilde syntax



On Fri, Jan 5, 2024 at 3:47 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> On 2024-01-05 15:27, Bart Schaefer wrote:
>
> On Fri, Jan 5, 2024 at 2:50 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> There really isn't any "parsing" per se -- internally, an "active"
> pattern character is represented differently than its literal
> counterpart.
>
> No way to see that unfold?

I don't even know what that would mean.  It's like asking to see
strcpy() "unfold."  The only difference is that when say a "*" is in
in the input, a different byte is put into the "active" output.
Instrumenting that for casual observability would be stupidly slow in
the normal use case.

> I'd advocate for clear and *visible* ways of coding one or the other.

But that's just it:  The base case in zsh is that if you CAN see it
(and you don't see quotes around it) then it IS active, and if you
CAN'T see it (or you do see quotes) then it's literal.  The only time
you need to get fancy is when you've deliberately hidden something
("inside" a parameter) and you need to expose it.  In most shells
other than zsh the patterns are active whether you can see them or
not, unless you see quotes, which means you see a lot of quotes.  The
corollary to the base case is that parameter references expand in
double quotes but not in single quotes, but expanding does not mean
making the contents active.

> "One of the endless problems with zsh -- or any other shell -- is that there are places where entered characters are presumed to be literal -- but can be forced to indicate some action or command -- and other places where entered characters are presumed to be actions -- but can be forced to become literal characters."

That's close to a complete mischaracterization.  Or conversely, it's
true of every programming language, just with differences of syntax.




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