From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: here document within a switch fails to parse.
Date: Thu, 7 Jan 2021 15:32:48 +0000 [thread overview]
Message-ID: <20210107153248.GA25249@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <d815953f-f3ef-a08d-8223-d970cbb14736@eastlink.ca>
Ray Andrews wrote on Wed, Jan 06, 2021 at 23:55:59 -0800:
> On 2021-01-06 11:18 a.m., Bart Schaefer wrote:
> > On Wed, Jan 6, 2021 at 9:17 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
> > > Still I'd expect the here document
> > > to be simply removed before parsing.
> > Think again about what you just wrote?
> >
> > The parser is what determines where the here document begins and ends;
> > parsing IS what removes it.
> >
> Well yes. I should have said that I'd expect it to be removed at the same
> level that comments are removed. Perhaps as Lawrence says this is not a good
> way to make comment blocks but apart from the one issue above, it seems
> entirely workable.
Do consider treating the language as the independent variable and your
expectations as the dependent one, rather than the other way around.
The syntax means what it means, not what you wish it meant. Heredocs
are string literals and input redirections, not comments. They don't
get "removed". (Just try «:() { nl "$@" }».)
The syntax is stateful. Heredocs aren't valid everywhere in the shell
grammar, just like the contraction "aren't" aren't valid everywhere in
English grammar.
The construct you use has side-effects you've overlooked, which mean
your fashion of comments will backfire in a way that you don't see yet.
You really should stick to writing idiomatic code. (-workers@: Ray's
fashion of comments resets lastval.)
Do you see why the error message I quoted upthread complained about the
semicolon and not about something else? And why «repeat dpkg-query
--list zsh» does what it does?
By the way, I wonder if the reason we're having this thread is that it
hasn't occurred to you that your $EDITOR may have facilities for
commenting or uncommenting multiple lines.
Daniel
next prev parent reply other threads:[~2021-01-07 15:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 15:13 Ray Andrews
2021-01-06 16:20 ` Daniel Shahaf
2021-01-06 17:17 ` Ray Andrews
2021-01-06 17:58 ` Lawrence Velázquez
2021-01-06 19:18 ` Bart Schaefer
2021-01-07 7:55 ` Ray Andrews
2021-01-07 15:32 ` Daniel Shahaf [this message]
2021-01-07 20:16 ` Ray Andrews
2021-01-08 15:27 ` Karsten Borgwaldt
2021-01-08 15:53 ` Lawrence Velázquez
2021-01-08 17:13 ` Ray Andrews
2021-01-08 18:06 ` Peter Stephenson
2021-01-08 19:39 ` Ray Andrews
2021-01-08 19:56 ` Bart Schaefer
2021-01-09 0:45 ` Ray Andrews
2021-01-09 17:28 ` Ray Andrews
2021-01-12 13:28 ` Daniel Shahaf
2021-01-12 14:45 ` Ray Andrews
2021-01-13 16:17 ` Daniel Shahaf
2021-01-13 21:57 ` Pier Paolo Grassi
2021-01-13 23:39 ` Ray Andrews
2021-01-13 23:54 ` Lawrence Velázquez
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=20210107153248.GA25249@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=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).