* comments break \ at end of line
@ 2000-08-24 21:29 Adam Spiers
2000-08-25 10:32 ` Peter Stephenson
0 siblings, 1 reply; 6+ messages in thread
From: Adam Spiers @ 2000-08-24 21:29 UTC (permalink / raw)
To: zsh workers mailing list
% foo () {
> echo hello, \
> # this is a comment
> world
> }
% foo
hello,
foo:3: command not found: world
which is the same issue as
% echo hello, \
> # comment
hello,
This may be intentional, but if so, it strikes me as a rather
undesirable feature, or at least one which you should be able to turn
off.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: comments break \ at end of line
2000-08-24 21:29 comments break \ at end of line Adam Spiers
@ 2000-08-25 10:32 ` Peter Stephenson
2000-08-25 14:38 ` Adam Spiers
0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2000-08-25 10:32 UTC (permalink / raw)
To: Zsh hackers list
Adam wrote:
> % foo () {
> > echo hello, \
> > # this is a comment
> > world
> > }
> % foo
> hello,
> foo:3: command not found: world
>
> which is the same issue as
>
> % echo hello, \
> > # comment
> hello,
>
> This may be intentional, but if so, it strikes me as a rather
> undesirable feature, or at least one which you should be able to turn
> off.
I don't really see how it could be any different. The `\' just skips the
newline, turning the line into `echo hello, # this is a comment'. `\'
never forces it into any different state of parsing, it only escapes the
next character. What are you suggesting? I don't see how you can turn it
off without writing a completely new (= bugridden) way of lexing.
--
Peter Stephenson <pws@csr.com> Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: comments break \ at end of line
2000-08-25 10:32 ` Peter Stephenson
@ 2000-08-25 14:38 ` Adam Spiers
2000-08-25 15:58 ` Andrej Borsenkow
2000-08-25 16:23 ` Bart Schaefer
0 siblings, 2 replies; 6+ messages in thread
From: Adam Spiers @ 2000-08-25 14:38 UTC (permalink / raw)
To: Zsh hackers list
Peter Stephenson (pws@csr.com) wrote:
> Adam wrote:
> > % foo () {
> > > echo hello, \
> > > # this is a comment
> > > world
> > > }
> > % foo
> > hello,
> > foo:3: command not found: world
> >
> > which is the same issue as
> >
> > % echo hello, \
> > > # comment
> > hello,
> >
> > This may be intentional, but if so, it strikes me as a rather
> > undesirable feature, or at least one which you should be able to turn
> > off.
>
> I don't really see how it could be any different. The `\' just skips the
> newline, turning the line into `echo hello, # this is a comment'. `\'
> never forces it into any different state of parsing, it only escapes the
> next character. What are you suggesting?
I'm suggesting that, in the case of the function, it turns it into
`echo hello, world', and in second case, it expects another line of
input, just as if you hadn't entered the comment line. After all,
comment lines are supposed to be ignored, aren't they? This seems far
more sensible behaviour to me: a) it's useful to be able to
intersperse comments with continuation lines, and b) if you didn't
want the continuation happening, you wouldn't have included the
backslashes in the first place.
> I don't see how you can turn it
> off without writing a completely new (= bugridden) way of lexing.
As is probably already obvious, I'm fairly ignorant of zsh's lexing
and parsing. At what stage do comments get dropped? I would have
thought that if they were dropped earlier on that this would achieve
what I want, but I'm just guessing.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: comments break \ at end of line
2000-08-25 14:38 ` Adam Spiers
@ 2000-08-25 15:58 ` Andrej Borsenkow
2000-08-25 16:23 ` Bart Schaefer
1 sibling, 0 replies; 6+ messages in thread
From: Andrej Borsenkow @ 2000-08-25 15:58 UTC (permalink / raw)
To: Adam Spiers, Zsh hackers list
> I'm suggesting that, in the case of the function, it turns it into
> `echo hello, world', and in second case, it expects another line of
> input, just as if you hadn't entered the comment line. After all,
> comment lines are supposed to be ignored, aren't they?
That is exactly what happens currently - everything from `#' up to the next
EOL is ignored.
This seems far
> more sensible behaviour to me: a) it's useful to be able to
> intersperse comments with continuation lines,
No, I am against it. It will turn into a nightmare.
echo foo \
#
# ... 57 lines of comments
#
echo bar
How do you like it?
and b)
if you didn't
> want the continuation happening, you wouldn't have included the
> backslashes in the first place.
>
It is not a continuation. It is simply removing of EOL no more no less (and so
it is documented). Yes, for all practical purposes it is the same as
continuation ...
> > I don't see how you can turn it
> > off without writing a completely new (= bugridden) way of lexing.
>
> As is probably already obvious, I'm fairly ignorant of zsh's lexing
> and parsing. At what stage do comments get dropped? I would have
> thought that if they were dropped earlier on that this would achieve
> what I want, but I'm just guessing.
>
But I just realised. In case of
echo foo \
# comment
bar
how do you want to indicate, that `bar' is not a comment? I mean
echo foo \
#comment \
bar
is the same as
echo foo #comment bar
that makes bar be happily ignored. The above change is trivial, but gains you
nothing. Anything else, I agree, is too error prone.
-andrej
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: comments break \ at end of line
2000-08-25 14:38 ` Adam Spiers
2000-08-25 15:58 ` Andrej Borsenkow
@ 2000-08-25 16:23 ` Bart Schaefer
1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2000-08-25 16:23 UTC (permalink / raw)
To: Adam Spiers, Zsh hackers list
On Aug 25, 3:38pm, Adam Spiers wrote:
} Subject: Re: comments break \ at end of line
}
} I'm suggesting that, in the case of the function, it turns it into
} `echo hello, world', and in second case, it expects another line of
} input, just as if you hadn't entered the comment line. After all,
} comment lines are supposed to be ignored, aren't they?
No, comment *lines* aren't supposed to be ignored. *Comments* are
supposed to be ignored. A comment is everything from the # up to BUT
NOT INCLUDING the newline.
If the comment included the newline, all sorts of parsing would go wrong:
if test foo # comment
then
Would become:
if test foo then
Which is certainly not what you meant.
A comment beginning in the first column is treated the same as a comment
beginning in any other column, which I think IS what you want; you don't
want the syntax of your program changed by the introduction of leading
whitespace, do you?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: comments break \ at end of line
@ 2000-08-25 10:35 Sven Wischnowsky
0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2000-08-25 10:35 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> Adam wrote:
> > % foo () {
> > > echo hello, \
> > > # this is a comment
> > > world
> > > }
> > % foo
> > hello,
> > foo:3: command not found: world
> >
> > which is the same issue as
> >
> > % echo hello, \
> > > # comment
> > hello,
> >
> > This may be intentional, but if so, it strikes me as a rather
> > undesirable feature, or at least one which you should be able to turn
> > off.
>
> I don't really see how it could be any different. The `\' just skips the
> newline, turning the line into `echo hello, # this is a comment'. `\'
> never forces it into any different state of parsing, it only escapes the
> next character. What are you suggesting? I don't see how you can turn it
> off without writing a completely new (= bugridden) way of lexing.
And the /bin/sh, ksh and bash here behave the same.
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2000-08-25 16:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-24 21:29 comments break \ at end of line Adam Spiers
2000-08-25 10:32 ` Peter Stephenson
2000-08-25 14:38 ` Adam Spiers
2000-08-25 15:58 ` Andrej Borsenkow
2000-08-25 16:23 ` Bart Schaefer
2000-08-25 10:35 Sven Wischnowsky
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).