zsh-workers
 help / color / mirror / code / Atom feed
* indented heredocs
@ 2016-12-21 19:29 Dave Yost
  2016-12-21 19:50 ` Daniel Shahaf
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Dave Yost @ 2016-12-21 19:29 UTC (permalink / raw)
  To: zsh workers

[-- Attachment #1: Type: text/plain, Size: 1473 bytes --]

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.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-12-31 18:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-21 19:29 indented heredocs Dave Yost
2016-12-21 19:50 ` Daniel Shahaf
2016-12-21 20:38 ` Dave Yost
2016-12-21 22:10 ` Bart Schaefer
2016-12-21 23:04   ` Bart Schaefer
2016-12-22 19:04     ` Philippe Troin
2016-12-22 21:10       ` Bart Schaefer
2016-12-29  9:56       ` Vincent Lefevre
2016-12-29 22:31   ` Nikolay Aleksandrovich Pavlov (ZyX)
2016-12-30  2:56     ` Bart Schaefer
2016-12-31 18:11       ` Nikolay Aleksandrovich Pavlov (ZyX)

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).