Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Suggested "case" syntax extension
- X-seq: zsh-users 276
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: segal@xxxxxxxxxx (Morris M. Siegel)
- Subject: Re: Suggested "case" syntax extension
- Date: Tue, 9 Jul 1996 02:33:06 +0200 (MET DST)
- Cc: zsh-users@xxxxxxxxxxxxxxx, segal@xxxxxxxxxx
- In-reply-to: <9607081946.ZM7325@xxxxxxxxxx> from "Morris M. Siegel" at "Jul 8, 96 07:46:21 pm"
- Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary
- Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368
> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author