From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4322 invoked from network); 22 Feb 2005 18:03:39 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Feb 2005 18:03:39 -0000 Received: (qmail 10974 invoked from network); 22 Feb 2005 18:03:33 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Feb 2005 18:03:33 -0000 Received: (qmail 11285 invoked by alias); 22 Feb 2005 18:03:27 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20843 Received: (qmail 11271 invoked from network); 22 Feb 2005 18:03:27 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 22 Feb 2005 18:03:27 -0000 Received: (qmail 10697 invoked from network); 22 Feb 2005 18:03:27 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 22 Feb 2005 18:03:22 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Tue, 22 Feb 2005 18:01:51 +0000 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 22 Feb 2005 18:04:13 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j1MI3J0D015416 for ; Tue, 22 Feb 2005 18:03:19 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j1MI3J3p015413 for ; Tue, 22 Feb 2005 18:03:19 GMT Message-Id: <200502221803.j1MI3J3p015413@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: Problem with named directories In-reply-to: <7e0054ed1841058b16ca27361b02fe7c@ee.oulu.fi> References: <7e0054ed1841058b16ca27361b02fe7c@ee.oulu.fi> Date: Tue, 22 Feb 2005 18:03:18 +0000 From: Peter Stephenson X-OriginalArrivalTime: 22 Feb 2005 18:04:13.0973 (UTC) FILETIME=[EACE0450:01C51908] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.5 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.5 =?ISO-8859-1?Q?Mika_Sepp=E4nen?= wrote: > Hi all, > > I write yesterday about problems with named directories. If I have > following definations in my zshenv-file: > > export foo="/home/user/dir/bar" > export bar="/fome/user/dir/bar/" > > Both work with cd-command, but only foo expands correctly to ~foo (from > %~ defination in prompt/title/etc). I write simple patch which changes > cmpdir-function so that it returns zero when only difference between > strings A and B is that A's last character is slash. I think it might be better to prune the name of the directory when it is assigned. This means ~bar is consistently treated as /fome/user/dir/bar throughout, which is after all the directory it refers to. The parameter value is not modified, of course. Index: Doc/Zsh/expn.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v retrieving revision 1.50 diff -u -r1.50 expn.yo --- Doc/Zsh/expn.yo 10 Jan 2005 17:31:25 -0000 1.50 +++ Doc/Zsh/expn.yo 22 Feb 2005 17:57:00 -0000 @@ -1138,6 +1138,8 @@ Named directories are typically home directories for users on the system. They may also be defined if the text after the `tt(~)' is the name of a string shell parameter whose value begins with a `tt(/)'. +Note that trailing slashes will be removed from the path to the directory +(though the original parameter is not modified). It is also possible to define directory names using the tt(-d) option to the tt(hash) builtin. Index: Src/utils.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/utils.c,v retrieving revision 1.72 diff -u -r1.72 utils.c --- Src/utils.c 1 Feb 2005 10:53:18 -0000 1.72 +++ Src/utils.c 22 Feb 2005 17:57:01 -0000 @@ -525,6 +525,7 @@ adduserdir(char *s, char *t, int flags, int always) { Nameddir nd; + char *eptr; /* We don't maintain a hash table in non-interactive shells. */ if (!interact) @@ -558,7 +559,10 @@ /* add the name */ nd = (Nameddir) zshcalloc(sizeof *nd); nd->flags = flags; - nd->dir = ztrdup(t); + eptr = t + strlen(t); + while (eptr > t + 1 && eptr[-1] == '/') + eptr--; + nd->dir = ztrduppfx(t, eptr - t); /* The variables PWD and OLDPWD are not to be displayed as ~PWD etc. */ if (!strcmp(s, "PWD") || !strcmp(s, "OLDPWD")) nd->flags |= ND_NOABBREV; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************