Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Problem with named directories



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.

diff -ruN zsh-4.3-20050221/Src/utils.c zsh-work/Src/utils.c
--- zsh-4.3-20050221/Src/utils.c    Tue Feb  1 12:53:18 2005
+++ zsh-work/Src/utils.c    Tue Feb 22 18:57:58 2005
@@ -620,6 +620,10 @@
        return 0;
    if (!*s && *t == '/')
        return 0;
+   if (!*t && *s == '/' && *(s+1) == '\0') {
+       *s = 0;
+       return 0;
+       }
     }
     return 1;
 }

Trailing slashs is removed to ensure that later use of that string wouldn't cause overflow.

Mika Seppänen


Messages sorted by: Reverse Date, Date, Thread, Author