From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3316 invoked from network); 19 Jan 2007 04:53:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 19 Jan 2007 04:53:25 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 85107 invoked from network); 19 Jan 2007 04:53:18 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 Jan 2007 04:53:18 -0000 Received: (qmail 18772 invoked by alias); 19 Jan 2007 04:53:11 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11134 Received: (qmail 18763 invoked from network); 19 Jan 2007 04:53:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 19 Jan 2007 04:53:10 -0000 Received: (qmail 83891 invoked from network); 19 Jan 2007 04:53:10 -0000 Received: from vms044pub.verizon.net (206.46.252.44) by a.mx.sunsite.dk with SMTP; 19 Jan 2007 04:53:03 -0000 Received: from torch.brasslantern.com ([71.116.79.148]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JC3008Q4MVWR7O2@vms044.mailsrvcs.net> for zsh-users@sunsite.dk; Thu, 18 Jan 2007 22:52:45 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id l0J4qhPn030785 for ; Thu, 18 Jan 2007 20:52:44 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id l0J4qhqk030784 for zsh-users@sunsite.dk; Thu, 18 Jan 2007 20:52:43 -0800 Date: Thu, 18 Jan 2007 20:52:43 -0800 From: Bart Schaefer Subject: Re: Case statement with ";|" [not implemented] In-reply-to: To: zsh-users@sunsite.dk Message-id: <070118205243.ZM30783@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: Comments: In reply to "Gerald Lai" "Case statement with ";|" [not implemented]" (Jan 18, 11:53am) On Jan 18, 11:53am, Gerald Lai wrote: } } My question is, shouldn't there be a way to do this: } === } case $mycase in } 0) } echo "mycase is 0" } ;; } } 1) } echo "mycase is 1" } ;| } } 2) } echo "mycase is 2" } ;| } } *) } echo "mycase is 1 or 2" } esac } === } Note that ";|" provides an OR-like separator (as opposed to the AND-like } ";&" separator) This analogy doesn't work. Semantically, the test for whether $mycase matches any one of the labels occurs once at the top of the statement. Control then jumps into the body as if with a GOTO, and thereafter all you're able to change with ;& is how early you exit from the body. It isn't anything like AND / OR. By comparison, your proposed ;| requires the interpreter to reproduce the pattern match test at every label, which implies storing the result of expanding $mycase, etc. Most languages don't allow one to hide quite that much complexity behind syntactic sugar.