From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5475 invoked from network); 21 Jul 2009 09:30:21 -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 new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 21 Jul 2009 09:30:21 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 91080 invoked from network); 21 Jul 2009 09:23:37 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Jul 2009 09:23:37 -0000 Received: (qmail 29469 invoked by alias); 21 Jul 2009 09:23:27 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27181 Received: (qmail 29450 invoked from network); 21 Jul 2009 09:23:25 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 21 Jul 2009 09:23:25 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [85.115.60.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id B1AAA803080A for ; Tue, 21 Jul 2009 11:23:22 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly22d.srv.mailcontrol.com (MailControl) with ESMTP id n6L9M26C029258 for ; Tue, 21 Jul 2009 10:23:20 +0100 Received: from news01 ([10.99.50.25]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Tue, 21 Jul 2009 10:22:54 +0100 Date: Tue, 21 Jul 2009 10:22:53 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: cd bugs Message-ID: <20090721102253.7a6496da@news01> In-Reply-To: References: 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: 21 Jul 2009 09:22:54.0060 (UTC) FILETIME=[D39792C0:01CA09E4] X-Scanned-By: MailControl A-09-20-00 (www.mailcontrol.com) on 10.68.0.132 X-Virus-Scanned: ClamAV 0.94.2/9594/Tue Jul 21 10:21:10 2009 on bifrost X-Virus-Status: Clean On Tue, 14 Jul 2009 21:59:14 +0000 (UTC) Eric Blake wrote: > POSIX requires cd to give output if a nonempty entry in CDPATH played a > role, or if 'cd -' was used. Therefore, this line demonstrates two zsh > bugs: > > $ zsh -c 'emulate -R sh; cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d' > $ bash -c 'cd /tmp; mkdir -p d; CDPATH=.; cd d; cd -; rmdir d' > /tmp/d > /tmp > $ > > while bash was correct in printing the absolute name of d and its parent. > > When fixing this, be sure that you don't break > > $ zsh -c 'emulate -R sh; mkdir foo; CDPATH=:; cd foo' > > since POSIX states that particular use must remain silent (an implicit . used > from an empty CDPATH entry is different than an explicit . in CDPATH). I think this should make the POSIX_CD option behave appropriately. Index: Doc/Zsh/options.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v retrieving revision 1.85 diff -u -r1.85 options.yo --- Doc/Zsh/options.yo 19 Jul 2009 19:08:49 -0000 1.85 +++ Doc/Zsh/options.yo 21 Jul 2009 09:20:37 -0000 @@ -130,6 +130,14 @@ 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. + +Also, if the option is set, the conditions under which the shell +prints the new directory after changing to it are modified. It is +no longer restricted to interactive shells (although printing of +the directory stack with tt(pushd) is still limited to interactive +shells); and any use of a component of tt(CDPATH), including a `tt(.)' but +excluding an empty component that is otherwise treated as `tt(.)', causes +the directory to be printed. ) pindex(PUSHD_IGNORE_DUPS) pindex(NO_PUSHD_IGNORE_DUPS) Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.232 diff -u -r1.232 builtin.c --- Src/builtin.c 19 Jul 2009 19:08:50 -0000 1.232 +++ Src/builtin.c 21 Jul 2009 09:20:37 -0000 @@ -972,8 +972,19 @@ if (!nocdpath) for (pp = cdpath; *pp; pp++) { if ((ret = cd_try_chdir(*pp, dest, hard))) { - if (strcmp(*pp, ".")) { - doprintdir++; + if (isset(POSIXCD)) { + /* + * For POSIX we need to print the directory + * any time CDPATH was used, except in the + * special case of an empty segment being + * treated as a ".". + */ + if (**pp) + doprintdir++; + } else { + if (strcmp(*pp, ".")) { + doprintdir++; + } } return ret; } @@ -1146,8 +1157,8 @@ pwd = new_pwd; set_pwd_env(); - if (isset(INTERACTIVE)) { - if (func != BIN_CD) { + if (isset(INTERACTIVE) || isset(POSIXCD)) { + if (func != BIN_CD && isset(INTERACTIVE)) { if (unset(PUSHDSILENT) && !quiet) printdirstack(); } else if (doprintdir) { -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK 'member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom'