[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: semicolon at beginning of line
From: |
Linda Walsh |
Subject: |
Re: semicolon at beginning of line |
Date: |
Sat, 07 Apr 2012 13:38:40 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
Elliott Forney wrote:
I wish bash would happily execute lines that begin with a semicolon,
i.e., treat it as a no-op followed by a command. The following
examples come to mind:
$ infloop& echo hello
hello
$ infloop&; echo hello
bash: syntax error near unexpected token `;'
$ echo hello; echo world
hello ; > world
$ echo hello;; echo world
bash: syntax error near unexpected token `;;' ***
$ ; echo hello world
bash: syntax error near unexpected token `;'
Any thoughts?
---
I like it (which probably isn't good with this crowd) -- but I think
the case I marked with *** could be more challenging -- since ;; is a
language token closing ")" in a case statement. But other than that,
a semi-colon being a substitute for a "\n", when it would
otherwise return a "semi-colon unexpected" message seems reasonable --
at least in non-posix mode (posix may require it...can't do anything
'different' there or risk incompats)
If it needs a value, a semi-colon wouldn't be a substitute for a value any
more than a newline, so
while;do;done
wouldn't be expected to work as you need a statement after 'while' and 'done' to
be eval'ed.
I've often wondered why it wasn't that way myself, but assumed I'd be told "it
just has to be that way, because....xxyz" (posix, or parser or something...)..
it makes too much sense not to do it for it not to have been done already..
Linda
(oft' resident contrarian)
- semicolon at beginning of line, Elliott Forney, 2012/04/07
- Re: semicolon at beginning of line,
Linda Walsh <=
- Re: semicolon at beginning of line, Steven W. Orr, 2012/04/08
- Re: semicolon at beginning of line, Joseph Fredette, 2012/04/08
- Re: semicolon at beginning of line, Elliott Forney, 2012/04/10
- Re: semicolon at beginning of line, Elliott Forney, 2012/04/10
- Re: semicolon at beginning of line, Maarten Billemont, 2012/04/10
- Re: semicolon at beginning of line, Elliott Forney, 2012/04/10
- Re: semicolon at beginning of line, Clark Wang, 2012/04/11