From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17295 invoked from network); 3 Mar 2009 17:23:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Mar 2009 17:23:43 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 58036 invoked from network); 3 Mar 2009 17:23:37 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Mar 2009 17:23:37 -0000 Received: (qmail 9647 invoked by alias); 3 Mar 2009 17:23:32 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26675 Received: (qmail 9638 invoked from network); 3 Mar 2009 17:23:32 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 3 Mar 2009 17:23:32 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id D77F68058F82 for ; Tue, 3 Mar 2009 18:23:28 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly24g.srv.mailcontrol.com (MailControl) with ESMTP id n23HNMin030504 for ; Tue, 3 Mar 2009 17:23:26 GMT Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Tue, 3 Mar 2009 17:23:24 +0000 Date: Tue, 3 Mar 2009 17:23:24 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: zsh regards reserved word as candidate for alias substitution Message-ID: <20090303172324.72e939c8@news01> In-Reply-To: <20090225001717.GU1246@prunille.vinc17.org> References: <20090225001717.GU1246@prunille.vinc17.org> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 03 Mar 2009 17:23:24.0156 (UTC) FILETIME=[C1D61BC0:01C99C24] X-Scanned-By: MailControl A_08_51_00 (www.mailcontrol.com) on 10.71.0.134 X-Virus-Scanned: ClamAV 0.92.1/9065/Tue Mar 3 11:43:41 2009 on bifrost X-Virus-Status: Clean On Wed, 25 Feb 2009 01:17:17 +0100 Vincent Lefevre wrote: > I've reported the following bug on > > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=516998 > > POSIX.1-2008 says[*]: > > 2.3.1 Alias Substitution > [...] However, reserved words in correct grammatical context > shall not be candidates for alias substitution. It's hardly worth an option, but it's best to keep options doing what they say... Index: Doc/Zsh/options.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v retrieving revision 1.76 diff -u -r1.76 options.yo --- Doc/Zsh/options.yo 14 Feb 2009 13:35:37 -0000 1.76 +++ Doc/Zsh/options.yo 3 Mar 2009 17:22:02 -0000 @@ -1708,6 +1708,43 @@ This option is for compatibility with older versions of the shell and is not recommended in new code. ) +pindex(POSIX_ALIASES) +pindex(NO_POSIX_ALIASES) +pindex(POSIXALIASES) +pindex(NOPOSIXALIASES) +item(tt(POSIX_ALIASES) )( +When this option is set, reserved words are not candidates for +alias expansion: it is still possible to declare any of them as an alias, +but the alias will never be expanded. Reserved words are +tt(!), +tt([[), +tt({), +tt(}), +tt(case), +tt(coproc), +tt(do), +tt(done), +tt(elif), +tt(else), +tt(end), +tt(esac), +tt(fi), +tt(for), +tt(foreach), +tt(function), +tt(if), +tt(nocorrect), +tt(repeat), +tt(select), +tt(then), +tt(time), +tt(until), +tt(while). + +Alias expansion takes place while text is being read; hence when this +option is set it does not take effect until the end of any function or +other piece of shell code evaluated as one unit. +) pindex(POSIX_BUILTINS) pindex(NO_POSIX_BUILTINS) pindex(POSIXBUILTINS) Index: Src/lex.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/lex.c,v retrieving revision 1.51 diff -u -r1.51 lex.c --- Src/lex.c 27 Feb 2009 10:24:16 -0000 1.51 +++ Src/lex.c 3 Mar 2009 17:22:02 -0000 @@ -1748,9 +1748,11 @@ if (tok == STRING) { /* Check for an alias */ - if (!noaliases && isset(ALIASESOPT)) { + if (!noaliases && isset(ALIASESOPT) && + (!isset(POSIXALIASES) || + !reswdtab->getnode(reswdtab, zshlextext))) { char *suf; - + an = (Alias) aliastab->getnode(aliastab, zshlextext); if (an && !an->inuse && ((an->node.flags & ALIAS_GLOBAL) || incmdpos || inalmore)) { Index: Src/options.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/options.c,v retrieving revision 1.47 diff -u -r1.47 options.c --- Src/options.c 11 Feb 2009 20:42:16 -0000 1.47 +++ Src/options.c 3 Mar 2009 17:22:02 -0000 @@ -198,6 +198,7 @@ {{NULL, "octalzeroes", OPT_EMULATE|OPT_SH}, OCTALZEROES}, {{NULL, "overstrike", 0}, OVERSTRIKE}, {{NULL, "pathdirs", OPT_EMULATE}, PATHDIRS}, +{{NULL, "posixaliases", OPT_EMULATE|OPT_BOURNE}, POSIXALIASES}, {{NULL, "posixbuiltins", OPT_EMULATE|OPT_BOURNE}, POSIXBUILTINS}, {{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS}, {{NULL, "printeightbit", 0}, PRINTEIGHTBIT}, Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.153 diff -u -r1.153 zsh.h --- Src/zsh.h 19 Feb 2009 10:12:39 -0000 1.153 +++ Src/zsh.h 3 Mar 2009 17:22:02 -0000 @@ -1933,6 +1933,7 @@ OCTALZEROES, OVERSTRIKE, PATHDIRS, + POSIXALIASES, POSIXBUILTINS, POSIXIDENTIFIERS, PRINTEIGHTBIT, Index: Test/A02alias.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/A02alias.ztst,v retrieving revision 1.6 diff -u -r1.6 A02alias.ztst --- Test/A02alias.ztst 27 Mar 2008 09:41:13 -0000 1.6 +++ Test/A02alias.ztst 3 Mar 2009 17:22:02 -0000 @@ -25,3 +25,14 @@ \bar \bar 0:Aliasing with a backslash >bar + + (alias '!=echo This command has the argument' + eval 'print Without + ! true' + setopt posixaliases + eval 'print With + ! true') +1:POSIX_ALIASES option +>Without +>This command has the argument true +>With -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070