Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
indented heredocs
- X-seq: zsh-workers 40220
- From: Dave Yost <Dave@xxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: indented heredocs
- Date: Wed, 21 Dec 2016 11:29:17 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:mime-version:subject:message-id:date:to; bh=LvfaDn5EPFByjh8Zw30U/SCzOx4ekkSj+gQowPZCARI=; b=S06E6j9RK1ZfnfELhKEg5of48DuvuL2xiQPZk1RadRLjpisgR7jFUeEoUxUTzxMgda 5kARs3AF/WoLXOWzYlDmpAlu0pKebnuF+Ut0dNgejWzHMHo7m8SMX2BDSYTGldZ+fZks HxXIgzlujtZKeinvVtCVKKzbtD7pe+qf16dAOyLdvOYz8N+LM8WrdKTHXoWE918rU8CM iMnblNH+Pp+vBuARTmeR1UNnzQ/YLUoVwmYh3v3aUzOA70BptfKLmJtE4f/RYPnirLcl PiUuZI7ERiGm6TXm25+Z3KBO/MpO3dpbxGC3hnXXXVPwxuceTmxUnvk7EarC6WZyN7+y i+xQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Sender: Dave Yost <daveyostcom@xxxxxxxxx>
Today we have this:
0 Wed 10:53:18 ~
204 Z% cat <<xx
foo
bar
xx
foo
bar
0 Wed 10:53:33 ~
205 Z%
Surely people have thought of this (Alternative 1):
0 Wed 10:53:53 ~
205 Z% cat <<xx
foo
bar
xx
foo
bar
0 Wed 10:53:53 ~
206 Z%
but shells don’t do that.
I ran this idea by Steve Bourne and asked him why indenting was not allowed.
> I never considered the indent idea. It's a good idea although I don't like the idea of post processing the temp file to remove the
> leading white space. I agree the way it is now is not easy to look at, and I can't think of a way to have the ident amount specified
> in advance of reading the document.
BTW, of historical interest, he also said he stole the heredoc idea from somebody else at Cambridge <https://www.youtube.com/watch?v=FI_bZhV7wpI#t=21m8s>.
I suggested this (Alternative 2), which he liked:
0 Wed 10:53:53 ~
206 Z% cat \
<<xx
foo
bar
xx
foo
bar
0 Wed 10:54:10 ~
207 Z%
He also suggested
> You could find another symbol after < Right now <xxx is file <<yyy is heredoc <<< is string. Other meta symbols
> are available which now would cause syntax error.
I don’t think that would help anything. If the parser doesn’t know how to do the new syntax with the existing << operator, you’ll get an error, and if the parser doesn’t know the new operator, you’ll get an error. Same difference.
I propose Alternative 2.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author