help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Why "; ;" is a syntax error?


From: Greg Wooledge
Subject: Re: [Help-bash] Why "; ;" is a syntax error?
Date: Wed, 24 Jun 2015 09:33:15 -0400
User-agent: Mutt/1.4.2.3i

I believe you forgot to Cc: the list.

On Wed, Jun 24, 2015 at 03:19:10PM +0200, address@hidden wrote:
> On 2015-06-24 14:20, Greg Wooledge wrote:
> >On Wed, Jun 24, 2015 at 10:15:39PM +1000, Matthew Cengia wrote:
> >>(I honestly can't understand the value in
> >>questioning the grammar in this manner)
> >
> >Peng is very confused.  The syntax defines what is LEGAL.  Everything 
> >that
> >does not conform to the syntax is a syntax error.  So asking "why is 
> >___
> >a syntax error" is a really stupid question.  It's a syntax error 
> >because
> >it's not one of the allowed constructs.  That's it.
> 
> I think that Peng's question can be rephrased like this:
> 
> Two empty statements (i.e. "; ;") are valid C. Why is bash syntax 
> defined in a way that disallows it? What's the rationale for this 
> decision?

Because it probably wasn't a "decision".  The syntax was developed by
Stephen Bourne at Bell Labs in 1977.  I'm sure he never gave much thought
to "Hey, maybe we should allow people to put empty commands all over
the place."  Why would he?  And even if he did briefly entertain such
a silly notion, I'm sure the work involved in rewriting the grammar to
allow that, and the additional size of the executable on 1977 hardware,
would have argued against it.

> Peng, note that bash disallows even a single empty statement:
> 
> ---8<---
> #!/bin/bash
> echo before;
> ;
> echo after;
> ---8<---
> 
> produces:
> 
> ---8<---
> before
> bash: line 2: syntax error near unexpected token `;'
> bash: line 2: `;'
> ---8<---
> 
> >Just stop writing broken crap.  And stop asking why the broken crap you
> >wrote is broken.
> 
> Best regards
> --
> Greg Navis



reply via email to

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