From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id GAA07102 for ; Wed, 10 Jul 1996 06:23:59 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id QAA28269; Tue, 9 Jul 1996 16:18:16 -0400 (EDT) Resent-Date: Tue, 9 Jul 1996 16:10:23 -0400 (EDT) From: segal@morgan.com (Morris M. Siegel) Date: Tue, 9 Jul 1996 16:09:07 -0400 Message-Id: <9607091609.ZM9713@morgan.com> In-Reply-To: Zoltan Hidvegi "Re: Suggested "case" syntax extension" (Jul 9, 2:33am) References: <199607090033.CAA11237@bolyai.cs.elte.hu> X-Mailer: Z-Mail (3.2.1 10oct95) To: Zoltan Hidvegi Subject: Re: Suggested "case" syntax extension Cc: zsh-users@math.gatech.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"_c3cq.0.ak6.kohun"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/278 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Jul 9, 2:33am, Zoltan Hidvegi wrote: > Subject: Re: Suggested "case" syntax extension > > Newer versions of ksh allow an optional '(' before each pattern in a case > > statement, complementary to the mandatory ')' following the pattern. As > > well as being esthetically symmetric, this also facilitates verifying that > > a shell script has balanced parentheses (e.g. with the '%' command in vi). > > > > It seems that zsh still recognizes only the classic Bourne shell syntax for > > "case", with the ')' but no optional '('. Considering all the syntactic > > variation zsh supports, it would be quite reasonable for zsh to allow a > > leading '(', thereby enhancing compatibility with ksh scripts. Although > > I have not looked into the zsh source, I imagine this should not pose an > > implementation problem. > > Zsh accepts an optional leading '(' since 2.6-beta21. POSIX 1003.2 > requires this. It also allows us to use case sttement in $(...) command > substitutions (of course even a normal case should work in a command > substitution but the zsh implementation requires ballanced parentheses like > bash and pdksh). > > Zsh is not completely ksh compatible here since due to the enhanced glob > pattern syntax recognized by zsh if there is a leading '(' the closing ')' > must be delimited with a blank from the command following that. So > > case foo in > (f*)echo yes;; > (*)echo no;; > esac > > does not work in zsh but > > case foo in > (f*) echo yes;; > (*) echo no;; > esac > > works. > > Zoltan >-- End of excerpt from Zoltan Hidvegi ______________________________________ I'm glad to learn this has already been implemented. (The last time I tried it was with 2.6-beta20, I believe.) However, I double-checked in the zsh-3.0-pre2 distribution, and both man/man1/zshmisc.1 and Doc/zshmisc.man lack any mention of an optional leading '('. This should be fairly easy to remedy. -- Morrie Siegel