From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@sunsite.dk
Subject: Re: cd bugs
Date: Sun, 19 Jul 2009 20:00:41 +0100 [thread overview]
Message-ID: <20090719200041.10571f74@pws-pc> (raw)
In-Reply-To: <loom.20090714T222350-609@post.gmane.org>
On Tue, 14 Jul 2009 22:30:33 +0000 (UTC)
Eric Blake <ebb9@byu.net> wrote:
> Another bug - POSIX requires that CDPATH be searched prior to ., regardless of
> whether CDPATH contains an explicit . or an empty entry.
Here's the option for this---obviously the other POSIX behaviour can be
associated with it, I just haven't done that here.
I also haven't bothered with optimising the case where we already tested
"." within CDPATH, it's not worth the extra code.
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.123
diff -u -r1.123 builtins.yo
--- Doc/Zsh/builtins.yo 2 Jul 2009 13:48:29 -0000 1.123
+++ Doc/Zsh/builtins.yo 19 Jul 2009 18:56:20 -0000
@@ -183,6 +183,9 @@
successful. If `tt(.)' occurs in tt(cdpath), then tt(cdpath) is searched
strictly in order so that `tt(.)' is only tried at the appropriate point.
+The order of testing tt(cdpath) is modified if the option tt(POSIX_CD)
+is set, as described in the documentation for the option.
+
If no directory is found, the option tt(CDABLE_VARS) is set, and a
parameter named var(arg) exists whose value begins with a slash, treat its
value as the directory. In that case, the parameter is added to the named
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.84
diff -u -r1.84 options.yo
--- Doc/Zsh/options.yo 12 Jul 2009 15:10:07 -0000 1.84
+++ Doc/Zsh/options.yo 19 Jul 2009 18:56:21 -0000
@@ -115,6 +115,22 @@
will be treated as referring to the physical parent, even if the preceding
path segment is a symbolic link.
)
+pindex(POSIX_CD)
+pindex(POSIXCD)
+pindex(NO_POSIX_CD)
+pindex(NOPOSIXCD)
+cindex(CDPATH, order of checking)
+item(tt(POSIX_CD))(
+Modifies the behaviour of tt(cd), tt(chdir) and tt(pushd) commands
+to make them more compatible with the POSIX standard. The behaviour with
+the option unset is described in the documentation for the tt(cd)
+builtin in
+ifzman(zmanref(zshbuiltins))\
+ifnzman(noderef(Shell Builtin Commands)).
+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.
+)
pindex(PUSHD_IGNORE_DUPS)
pindex(NO_PUSHD_IGNORE_DUPS)
pindex(PUSHDIGNOREDUPS)
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.231
diff -u -r1.231 builtin.c
--- Src/builtin.c 15 Jul 2009 08:43:31 -0000 1.231
+++ Src/builtin.c 19 Jul 2009 18:56:21 -0000
@@ -945,14 +945,23 @@
return NULL;
}
- /* if cdpath is being used, check it for . */
- if (!nocdpath)
+ /*
+ * If cdpath is being used, check it for ".".
+ * Don't bother doing this if POSIXCD is set, we don't
+ * need to know (though it doesn't actually matter).
+ */
+ if (!nocdpath && !isset(POSIXCD))
for (pp = cdpath; *pp; pp++)
if (!(*pp)[0] || ((*pp)[0] == '.' && (*pp)[1] == '\0'))
hasdot = 1;
- /* if there is no . in cdpath (or it is not being used), try the directory
- as-is (i.e. from .) */
- if (!hasdot) {
+ /*
+ * If
+ * (- there is no . in cdpath
+ * - or cdpath is not being used)
+ * - and the POSIXCD option is not set
+ * try the directory as-is (i.e. from .)
+ */
+ if (!hasdot && !isset(POSIXCD)) {
if ((ret = cd_try_chdir(NULL, dest, hard)))
return ret;
if (errno != ENOENT)
@@ -971,6 +980,15 @@
if (errno != ENOENT)
eno = errno;
}
+ /*
+ * POSIX requires us to check "." after CDPATH rather than before.
+ */
+ if (isset(POSIXCD)) {
+ if ((ret = cd_try_chdir(NULL, dest, hard)))
+ return ret;
+ if (errno != ENOENT)
+ eno = errno;
+ }
/* handle the CDABLEVARS option */
if ((ret = cd_able_vars(dest))) {
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.50
diff -u -r1.50 options.c
--- Src/options.c 10 Jul 2009 11:08:48 -0000 1.50
+++ Src/options.c 19 Jul 2009 18:56:22 -0000
@@ -200,6 +200,7 @@
{{NULL, "pathdirs", OPT_EMULATE}, PATHDIRS},
{{NULL, "posixaliases", OPT_EMULATE|OPT_BOURNE}, POSIXALIASES},
{{NULL, "posixbuiltins", OPT_EMULATE|OPT_BOURNE}, POSIXBUILTINS},
+{{NULL, "posixcd", OPT_EMULATE|OPT_BOURNE}, POSIXCD},
{{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS},
{{NULL, "posixjobs", OPT_EMULATE|OPT_BOURNE}, POSIXJOBS},
{{NULL, "printeightbit", 0}, PRINTEIGHTBIT},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.160
diff -u -r1.160 zsh.h
--- Src/zsh.h 11 Jul 2009 16:43:00 -0000 1.160
+++ Src/zsh.h 19 Jul 2009 18:56:22 -0000
@@ -1966,6 +1966,7 @@
PATHDIRS,
POSIXALIASES,
POSIXBUILTINS,
+ POSIXCD,
POSIXIDENTIFIERS,
POSIXJOBS,
PRINTEIGHTBIT,
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2009-07-19 19:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-14 21:59 Eric Blake
2009-07-14 22:30 ` Eric Blake
2009-07-19 19:00 ` Peter Stephenson [this message]
2009-07-15 3:28 ` Eric Blake
2009-07-15 8:45 ` Peter Stephenson
2009-07-21 9:22 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090719200041.10571f74@pws-pc \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).