[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reporting of "{x" non ideal

From: Chet Ramey
Subject: Re: reporting of "{x" non ideal
Date: Tue, 27 Nov 2001 16:59:55 -0500

> Dan Jacobson <address@hidden> wrote:
> > $ test a||{false;true;}&&echo $?
> > bash: syntax error near unexpected token `&'
> >
> > no it's not, it's near "{",
> I'd say it's *near* "||" and ";", and, more to the point, that it *is*
> "{false".  I don't know if that's how the tokenizer works, but
> claiming that "{false" is a token, even if it's not, would probably be
> the most useful error message.

The problem is that `{' and '}' are reserved words, not operators, and
are only recognized as such when reserved words are recognized: in a
command position, and separated by whitespace from other input.

The statement is parsed as

test a || {false
}&&echo $?

The first two are obviously valid commands.  The last is a syntax error.
The offending token is `&'.

I don't have any time right now, but I suppose I could look at what
the parser's doing with that last statement.  Maybe that should echo `0'.


``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]