Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Feature Request] Adding option to support triple quotes
- X-seq: zsh-workers 44677
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [Feature Request] Adding option to support triple quotes
- Date: Fri, 16 Aug 2019 22:31:11 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=iJrYR7Sgp87obw56u9cgnpIIAvSYycaToAOPBDWBHrk=; b=cEQUrRDNauY6JfLpTZPUo3zDIm7yFBftOra53m9J2PaW+gzw602D2ShAdH6yWuUHgf WL4b3+PlDGdKAyheJtVc6uK+lJQLoktNw80Rehts6tDWo+whv+fYvcIH38x3XGMXShu4 Fz3Vt87nMv5TVmcMpzBnGbxm7Vv8xafxDfWbgBWko05k0ELkMJJosx2y4ENFf3x5k4qq BfLLl6IDdpCoJjdNXzxBQ2MFqZDf/HBcLx+wiLFmXQOvvD41FuDfTviAwJVNKgnU/153 5eRog3bdysT81iC1u3dnPBmwR2VBatPg0oWqflAlzFOYxEKTblrBjnY0j3MMAK346qMi oxOg==
- In-reply-to: <AAFFC725-E38F-4307-8E21-8A443FC0FFBC@icloud.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <2c845fb0-d628-400f-a805-ad8356b6d87a@www.fastmail.com> <7EBD1ADA-7179-4EEF-97CA-DBE4371D80D6@icloud.com> <876f807b-dfdd-4246-8cfe-7cf6f373ac88@www.fastmail.com> <f053e72e-e22e-4729-a2de-eaa712119728@www.fastmail.com> <AAFFC725-E38F-4307-8E21-8A443FC0FFBC@icloud.com>
On Thu, Aug 15, 2019 at 6:13 PM Aryn Starr <whereislelouch@xxxxxxxxxx> wrote:
>
> The only preventive measure I can think of is to tell users to check zsh’s version at the very start and exit noisily ...
This right here is exactly why we have traditionally never built new
syntax that is an ambiguous superset of an existing syntax. If it's
not a syntax error in a version of the interpreter that doesn't
support it, it shouldn't be there at all. I've been staying out of
this discussion because it's all been theoretical so far, but tripling
quotation marks is a nonstarter for me.
A good relatively recent example of this is that you're allowed to write
{ stuff } always
{ other stuff }
but not
{ stuff }
always { other stuff }
So if you really want to make progress with this, start looking for
something more akin to perl's q{} and qq{} as already mentioned. The
difficult part is that the shell language uses "lexical pasting"
instead of a concatenation operator, so finding something that doesn't
already have another meaning is tricky.
One way around this is to introduce a new keyword. A candidate that
occurs to me is "let", because it's already a builtin and it's been
decades since I saw anybody use it. (Does anyone know of a program
named "let" with which this would collide, and that isn't already
basically unusable in zsh because of the builtin?) The "let" builtin
expects math expressions, which already have a limited syntax, so it's
easier to find something that would break in an old shell. For
example, a math expression can't begin with a colon, so that could
introduce a new quoting token.
This also means you can turn the syntax off with "disable" if you
don't want it, we don't have to create another setopt.
Qualification: I'm not sure the following suggestions would actually
error soon enough to prevent some downstream syntax from being
interpreted/executed, so this probably still needs more thought.
Nevertheless you could have (just throwing out examples)
let :"( this is like a triple double quoted argument to the ":" builtin )
let :'{ similarly a triple single quote , and look we can choose our delimiter }
let foo=:"{{{ assign to foo, and quote } and { by having the delimiter
repeat }}}
There are other characters that can't begin a math expression that
could be given other meanings, such as ^ and @ and %
let list=@{ :"( string one ) :'< string two > :^[ string three ] } #
no, I do not have any idea what :^ would mean ...
let hash=%{ key=:"( value ) }
Messages sorted by:
Reverse Date,
Date,
Thread,
Author