From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23718 invoked from network); 19 Jul 2009 19:01:12 -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.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 19 Jul 2009 19:01:12 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 54917 invoked from network); 19 Jul 2009 19:01:06 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 Jul 2009 19:01:06 -0000 Received: (qmail 26197 invoked by alias); 19 Jul 2009 19:00:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27167 Received: (qmail 26174 invoked from network); 19 Jul 2009 19:00:54 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 19 Jul 2009 19:00:54 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id 4D2338027106 for ; Sun, 19 Jul 2009 21:00:50 +0200 (CEST) Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090719190049.DCHP6742.mtaout01-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Sun, 19 Jul 2009 20:00:49 +0100 Received: from pws-pc ([81.107.42.185]) by aamtaout01-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090719190049.EHBC13254.aamtaout01-winn.ispmail.ntl.com@pws-pc> for ; Sun, 19 Jul 2009 20:00:49 +0100 Date: Sun, 19 Jul 2009 20:00:41 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: cd bugs Message-ID: <20090719200041.10571f74@pws-pc> In-Reply-To: References: X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.2; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=9vXuR5GGAAAA:8 a=NLZqzBF-AAAA:8 a=aqMN0ScsRv0DgtJch_AA:9 a=Ok87UB6eqdUgf_F_MqEA:7 a=kFNQ4dKhaVIihY26SLXxfGMBJCYA:4 a=eDFNAWYWrCwA:10 a=_dQi-Dcv4p4A:10 X-Virus-Scanned: ClamAV 0.94.2/9589/Sun Jul 19 05:14:56 2009 on bifrost X-Virus-Status: Clean On Tue, 14 Jul 2009 22:30:33 +0000 (UTC) Eric Blake wrote: > Another bug - POSIX requires that CDPATH be searched prior to ., regardless of > whether CDPATH contains an explicit . or an empty entry. Here's the option for this---obviously the other POSIX behaviour can be associated with it, I just haven't done that here. I also haven't bothered with optimising the case where we already tested "." within CDPATH, it's not worth the extra code. Index: Doc/Zsh/builtins.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v retrieving revision 1.123 diff -u -r1.123 builtins.yo --- Doc/Zsh/builtins.yo 2 Jul 2009 13:48:29 -0000 1.123 +++ Doc/Zsh/builtins.yo 19 Jul 2009 18:56:20 -0000 @@ -183,6 +183,9 @@ successful. If `tt(.)' occurs in tt(cdpath), then tt(cdpath) is searched strictly in order so that `tt(.)' is only tried at the appropriate point. +The order of testing tt(cdpath) is modified if the option tt(POSIX_CD) +is set, as described in the documentation for the option. + If no directory is found, the option tt(CDABLE_VARS) is set, and a parameter named var(arg) exists whose value begins with a slash, treat its value as the directory. In that case, the parameter is added to the named Index: Doc/Zsh/options.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v retrieving revision 1.84 diff -u -r1.84 options.yo --- Doc/Zsh/options.yo 12 Jul 2009 15:10:07 -0000 1.84 +++ Doc/Zsh/options.yo 19 Jul 2009 18:56:21 -0000 @@ -115,6 +115,22 @@ will be treated as referring to the physical parent, even if the preceding path segment is a symbolic link. ) +pindex(POSIX_CD) +pindex(POSIXCD) +pindex(NO_POSIX_CD) +pindex(NOPOSIXCD) +cindex(CDPATH, order of checking) +item(tt(POSIX_CD))( +Modifies the behaviour of tt(cd), tt(chdir) and tt(pushd) commands +to make them more compatible with the POSIX standard. The behaviour with +the option unset is described in the documentation for the tt(cd) +builtin in +ifzman(zmanref(zshbuiltins))\ +ifnzman(noderef(Shell Builtin Commands)). +If the option is set, the shell does not test for directories beneath +the local directory (`tt(.)') until after all directories in tt(cdpath) +have been tested. +) pindex(PUSHD_IGNORE_DUPS) pindex(NO_PUSHD_IGNORE_DUPS) pindex(PUSHDIGNOREDUPS) Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.231 diff -u -r1.231 builtin.c --- Src/builtin.c 15 Jul 2009 08:43:31 -0000 1.231 +++ Src/builtin.c 19 Jul 2009 18:56:21 -0000 @@ -945,14 +945,23 @@ return NULL; } - /* if cdpath is being used, check it for . */ - if (!nocdpath) + /* + * If cdpath is being used, check it for ".". + * Don't bother doing this if POSIXCD is set, we don't + * need to know (though it doesn't actually matter). + */ + if (!nocdpath && !isset(POSIXCD)) for (pp = cdpath; *pp; pp++) if (!(*pp)[0] || ((*pp)[0] == '.' && (*pp)[1] == '\0')) hasdot = 1; - /* if there is no . in cdpath (or it is not being used), try the directory - as-is (i.e. from .) */ - if (!hasdot) { + /* + * If + * (- there is no . in cdpath + * - or cdpath is not being used) + * - and the POSIXCD option is not set + * try the directory as-is (i.e. from .) + */ + if (!hasdot && !isset(POSIXCD)) { if ((ret = cd_try_chdir(NULL, dest, hard))) return ret; if (errno != ENOENT) @@ -971,6 +980,15 @@ if (errno != ENOENT) eno = errno; } + /* + * POSIX requires us to check "." after CDPATH rather than before. + */ + if (isset(POSIXCD)) { + if ((ret = cd_try_chdir(NULL, dest, hard))) + return ret; + if (errno != ENOENT) + eno = errno; + } /* handle the CDABLEVARS option */ if ((ret = cd_able_vars(dest))) { Index: Src/options.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/options.c,v retrieving revision 1.50 diff -u -r1.50 options.c --- Src/options.c 10 Jul 2009 11:08:48 -0000 1.50 +++ Src/options.c 19 Jul 2009 18:56:22 -0000 @@ -200,6 +200,7 @@ {{NULL, "pathdirs", OPT_EMULATE}, PATHDIRS}, {{NULL, "posixaliases", OPT_EMULATE|OPT_BOURNE}, POSIXALIASES}, {{NULL, "posixbuiltins", OPT_EMULATE|OPT_BOURNE}, POSIXBUILTINS}, +{{NULL, "posixcd", OPT_EMULATE|OPT_BOURNE}, POSIXCD}, {{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS}, {{NULL, "posixjobs", OPT_EMULATE|OPT_BOURNE}, POSIXJOBS}, {{NULL, "printeightbit", 0}, PRINTEIGHTBIT}, Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.160 diff -u -r1.160 zsh.h --- Src/zsh.h 11 Jul 2009 16:43:00 -0000 1.160 +++ Src/zsh.h 19 Jul 2009 18:56:22 -0000 @@ -1966,6 +1966,7 @@ PATHDIRS, POSIXALIASES, POSIXBUILTINS, + POSIXCD, POSIXIDENTIFIERS, POSIXJOBS, PRINTEIGHTBIT, -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/