* [doogie@brainfood.com: Bug#163237: zsh barfs on valid shell] @ 2002-10-03 20:43 Clint Adams 2002-10-04 3:57 ` PATCH " Bart Schaefer 0 siblings, 1 reply; 3+ messages in thread From: Clint Adams @ 2002-10-03 20:43 UTC (permalink / raw) To: zsh-workers; +Cc: 163237-forwarded This happens under emulate -R sh as well. ----- Forwarded message from Adam Heath <doogie@brainfood.com> ----- adam@yakko:~$ for shell in ash bash zsh ksh; do echo -n "$shell:"; $shell -c 'case foo in (foo)echo foo;;(bar)echo bar;;esac';done ash:foo bash:foo zsh:zsh: parse error near `foo' ksh:foo adam@yakko:~$ for shell in ash bash zsh ksh; do echo -n "$shell:"; $shell -c 'case foo in (foo) echo foo;;(bar) echo bar;;esac';done ash:foo bash:foo zsh:foo ksh:foo http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_10_02 Scroll down a bit to the actual grammer(surrounded by <pre>): The case_item and case_item_ns show that there is no required space(or other break char) between the ')' and the compound_list. case_item_ns : pattern ')' linebreak | pattern ')' compound_list linebreak | '(' pattern ')' linebreak | '(' pattern ')' compound_list linebreak ; case_item : pattern ')' linebreak DSEMI linebreak | pattern ')' compound_list DSEMI linebreak | '(' pattern ')' linebreak DSEMI linebreak | '(' pattern ')' compound_list DSEMI linebreak ----- End forwarded message ----- ^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH Re: [doogie@brainfood.com: Bug#163237: zsh barfs on valid shell] 2002-10-03 20:43 [doogie@brainfood.com: Bug#163237: zsh barfs on valid shell] Clint Adams @ 2002-10-04 3:57 ` Bart Schaefer 2002-10-07 10:59 ` Peter Stephenson 0 siblings, 1 reply; 3+ messages in thread From: Bart Schaefer @ 2002-10-04 3:57 UTC (permalink / raw) To: Clint Adams, zsh-workers; +Cc: 163237-forwarded 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 <doogie@brainfood.com> ----- } } 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH Re: [doogie@brainfood.com: Bug#163237: zsh barfs on valid shell] 2002-10-04 3:57 ` PATCH " Bart Schaefer @ 2002-10-07 10:59 ` Peter Stephenson 0 siblings, 0 replies; 3+ messages in thread From: Peter Stephenson @ 2002-10-07 10:59 UTC (permalink / raw) To: Zsh hackers list "Bart Schaefer" wrote: > 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 <doogie@brainfood.com> ----- > } > } 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]. > > 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. An option `case_balance_parens' would be a possibility. The reasoning for this would be (1) balancing the parentheses is neater anyway, so having a test to force better syntax is useful (2) inside $(...), balancing is essential, so using the option makes it consistent. It couldn't be on by default, though, so you wouldn't get it with `emulate zsh', which makes it less useful. The SH_GLOB test is definitely better for Bourne-style use. -- Peter Stephenson <pws@csr.com> Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ********************************************************************** ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-10-07 10:59 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-10-03 20:43 [doogie@brainfood.com: Bug#163237: zsh barfs on valid shell] Clint Adams 2002-10-04 3:57 ` PATCH " Bart Schaefer 2002-10-07 10:59 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).