From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14735 invoked from network); 4 Oct 2002 03:58:03 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 4 Oct 2002 03:58:03 -0000 Received: (qmail 8036 invoked by alias); 4 Oct 2002 03:57:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17760 Received: (qmail 8018 invoked from network); 4 Oct 2002 03:57:56 -0000 From: "Bart Schaefer" Message-Id: <1021004035721.ZM2643@candle.brasslantern.com> Date: Fri, 4 Oct 2002 03:57:21 +0000 In-Reply-To: <20021003204341.GD13111@dman.com> Comments: In reply to Clint Adams "[doogie@brainfood.com: Bug#163237: zsh barfs on valid shell]" (Oct 3, 4:43pm) References: <20021003204341.GD13111@dman.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Clint Adams , zsh-workers@sunsite.dk Subject: PATCH Re: [doogie@brainfood.com: Bug#163237: zsh barfs on valid shell] Cc: 163237-forwarded@bugs.debian.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 3, 4:43pm, Clint Adams wrote: } Subject: [doogie@brainfood.com: Bug#163237: zsh barfs on valid shell] } } This happens under emulate -R sh as well. } } ----- Forwarded message from Adam Heath ----- } } case foo in (foo)echo foo;;(bar)echo bar;;esac } zsh:zsh: parse error near `foo' This is because "(foo)echo" is being parsed as a file pattern [equivalent to "(foo|foo)echo" for those who don't immediately see why it's being parsed that way]. The syntax error thus is that there is no close paren after the pattern -- e.g. zsh is trying to parse one of case_item_ns : pattern ')' compound_list linebreak case_item : pattern ')' compound_list DSEMI linebreak and therefore fails. This is an inherent ambiguity in using parens for pattern grouping and is going to have to stay the way it is when not in emulation mode. Fortunately the emulation fix is not as difficult as I feared it would be. Index: Src/lex.c =================================================================== diff -c -r1.7 lex.c --- Src/lex.c 1 Sep 2002 16:47:38 -0000 1.7 +++ Src/lex.c 4 Oct 2002 03:45:30 -0000 @@ -993,8 +993,12 @@ c = Outbrack; break; case LX2_INPAR: - if ((sub || in_brace_param) && isset(SHGLOB)) - break; + if (isset(SHGLOB)) { + if (sub || in_brace_param) + break; + if (incasepat && !len) + return INPAR; + } if (!in_brace_param) { if (!sub) { e = hgetc(); Index: Src/parse.c =================================================================== diff -c -r1.14 parse.c --- Src/parse.c 12 Sep 2002 07:59:07 -0000 1.14 +++ Src/parse.c 4 Oct 2002 03:53:08 -0000 @@ -1042,6 +1042,8 @@ yylex(); if (tok == OUTBRACE) break; + if (tok == INPAR) + yylex(); if (tok != STRING) YYERRORV(oecused); if (!strcmp(tokstr, "esac")) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net