🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Jon R Ferro Thu, 08 Feb 1990 04:21
Bug in bash/parse.y?
#1151
Author: Jon R Ferro
Date: Thu, 08 Feb 1990 04:21
64 lines
2328 bytes
It appears that the comment above the rule for 'list' in
apple-gunkies:/home/gd/gnu/bash/parse.y does not match the actual
definition in the file:

=========
    /* A list allows leading or trailing newlines and
       newlines as operators (equivalent to semicolons).
==>    It must end with a newline or semicolon.
       Lists are used within commands such as if, for, while.  */

    list:		newlines list0
			    { $$ = $2; }
	    ;

?=> list0:		list1
	    |	list1 '\n' newlines
	    |	list1 '&' newlines
			    { $$ = command_connect ($1, 0, '&'); }
	    |	list1 ';' newlines

	    ;

    list1:		list1 AND_AND newlines list1
	.....
	    |	command
	    ;

========

By making different choices for the expansion of list0, a list can end
in a semicolon, a carriage return, an ampersand (reasonable, but not
listed) or nothing in particular (a bug?).  I know of no example that
fails specifically because of this, but removing the expansion labelled
'?=>' may cause better detection of syntax errors for cases like this:

    bash$ for file in *; do if test -d $file then ls -d $file; fi; done
					    ^		     
					    missing semicolon

for which bash only gives the error "syntax error near `;'".

Another possible correction to this wretched error message is the
addition of "error clauses" to the rule for shell_command such as:

    shell_command:
	    ....
	    |	IF list FI
			    { report_syntax_error ("Can't find 'then' (missing semicolon?)");
			      reset_parser ();
			    }

The actual cause of my error in typing that command line and starting
this whole search through the source code to see what was going wrong
was this information given to me by bash itself:

    bash$ help if
    if: if COMMANDS then COMMANDS [else COMMANDS] fi
		   ^		 ^
		   missing semicolons

If nothing else, could this help message be corrected to match those for
CASE and FOR?

Thanks.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads