[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash accepts script with incorrect syntax and goes into infinite loo
From: |
Dave B |
Subject: |
Re: bash accepts script with incorrect syntax and goes into infinite loop |
Date: |
Fri, 9 Oct 2009 11:46:16 +0100 |
User-agent: |
KMail/1.11.4 (Linux/2.6.28-15-generic; KDE/4.2.4; x86_64; ; ) |
On Friday 09 October 2009, Pierre Gaston wrote:
> > Well, it seems to me (and as stated in the bug report) that a "do" should
> > follow the "while read NAME;".
>
> the while syntax is like this:
> "while list; do list; done"
> and the manual says "A sequence of one or more newlines may appear in a
> list instead of a semicolon to delimit commands."
> so you can have:
>
> while command
> command
> do
>
> (the ; in the definition is probably there to keep the definition on one
> line, you can replace the ; in all the other definitions by a newline like:
> if command
> then
>
> This also works the same way in the other shells. For me it's not a bug.
Uhm, on a more accurate reading you're probably right. The POSIX syntax for
while is
while compound-list-1 do
compound-list-2
done
And "read NAME; echo NAME=$NAME" is a compound-list. So I was deceived by the
formatting, I think you are right. Thanks for correcting me.
--
D.