diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2005-02-22 18:23:16 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2005-02-22 18:23:16 +0000 |
commit | 85b63c0c0382310460bd616db583c16d1046eead (patch) | |
tree | 51797f01f75ff1644fabd30c40685f04b7ddcac5 /Src | |
parent | b83f0e229097626fa8e667486c48d7a3139d2e4a (diff) | |
download | zsh-85b63c0c0382310460bd616db583c16d1046eead.tar.gz zsh-85b63c0c0382310460bd616db583c16d1046eead.tar.xz zsh-85b63c0c0382310460bd616db583c16d1046eead.zip |
20844: prune trailing slashes from named directory
Diffstat (limited to 'Src')
-rw-r--r-- | Src/utils.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Src/utils.c b/Src/utils.c index 26e6b934a..0f4e0be8c 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -525,6 +525,7 @@ mod_export void 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,18 @@ adduserdir(char *s, char *t, int flags, int always) /* add the name */ nd = (Nameddir) zshcalloc(sizeof *nd); nd->flags = flags; - nd->dir = ztrdup(t); + eptr = t + strlen(t); + while (eptr > t && eptr[-1] == '/') + eptr--; + if (eptr == t) { + /* + * Don't abbreviate multiple slashes at the start of a + * named directory, since these are sometimes used for + * special purposes. + */ + nd->dir = ztrdup(t); + } else + 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; |