Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Cannot cd into --
- X-seq: zsh-workers 24656
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Cannot cd into --
- Date: Sun, 2 Mar 2008 21:17:44 +0000
- In-reply-to: <20080229221008.2c5d417e@buddha>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080229221008.2c5d417e@buddha>
On Fri, 29 Feb 2008 22:10:08 +0100
"Matthias B." <msbREMOVE-THIS@xxxxxxxxxxxxxxx> wrote:
> It doesn't seem to be possible with zsh to cd into a directory named --
>
> cd -- --
That's a bug, but possible not as egregious as you think: "cd --
-<number>" changes to an entry on the directory stack (and it's
special-cased so you don't need the leading "--"). There's no way
around that, so if the directory were called "-2" you'd still need to use
"./-2". Here it was treating the second - as a truncated negative
number. This just fixes cd---I'm not sure if the shell should ever
treat a - on its own in that fashion.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.187
diff -u -r1.187 builtin.c
--- Src/builtin.c 18 Feb 2008 03:18:03 -0000 1.187
+++ Src/builtin.c 2 Mar 2008 21:14:18 -0000
@@ -835,7 +835,8 @@
char *end;
doprintdir++;
- if (argv[0][1] && (argv[0][0] == '+' || argv[0][0] == '-')) {
+ if (argv[0][1] && (argv[0][0] == '+' || argv[0][0] == '-')
+ && strspn(argv[0]+1, "0123456789") == strlen(argv[0]+1)) {
dd = zstrtol(argv[0] + 1, &end, 10);
if (*end == '\0') {
if ((argv[0][0] == '+') ^ isset(PUSHDMINUS))
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author