Re: dash, ash for loop oddity

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

 



On Sun, Sep 21, 2008 at 02:33:59PM +0000, Maximilian Bernöcker wrote:
> Hi,
> 
> according to the grammar
> <http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_10_02>
> 
> | for_clause       : For name linebreak                            do_group
> |                  | For name linebreak in          sequential_sep do_group
> |                  | For name linebreak in wordlist sequential_sep do_group
> | [...]
> | linebreak        : newline_list
> |                  | /* empty */
> 
> the following script should be legal:

Thanks.  Fixed with this patch.

commit 22e8fb41be2bfd0e6757c80d6365af9080a3b4a1
Author: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date:   Sun Feb 22 19:47:52 2009 +0800

    [PARSER] Allow newlines after var name in for statements
    
    POSIX allows newlines before the "in" keyword in for statements
    so we should too.
    
    Thanks to Maximilian Bernöcker for reporting this.
    
    Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

diff --git a/ChangeLog b/ChangeLog
index dcb7182..d7e0f79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
 	* Fix dowait signal race.
 	* Remove EXSIG.
 	* Do not close stderr when /dev/tty fails to open.
+	* Allow newlines after var name in for statements.
 
 2009-01-14  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
 
diff --git a/src/parser.c b/src/parser.c
index ab66f30..425c457 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -357,7 +357,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
 		n1 = (union node *)stalloc(sizeof (struct nfor));
 		n1->type = NFOR;
 		n1->nfor.var = wordtext;
-		checkkwd = CHKKWD | CHKALIAS;
+		checkkwd = CHKNL | CHKKWD | CHKALIAS;
 		if (readtoken() == TIN) {
 			app = &ap;
 			while (readtoken() == TWORD) {
@@ -383,7 +383,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
 			 * Newline or semicolon here is optional (but note
 			 * that the original Bourne shell only allowed NL).
 			 */
-			if (lasttoken != TNL && lasttoken != TSEMI)
+			if (lasttoken != TSEMI)
 				tokpushback++;
 		}
 		checkkwd = CHKNL | CHKKWD | CHKALIAS;

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux