diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-07-19 19:07:14 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-07-19 19:07:14 +0000 |
commit | 606cfb5a5e65c80d88fc90169200cea404c16796 (patch) | |
tree | 3912e7287610f77fd37c21fafc2ba6563aacb549 | |
parent | 0b8d247f6b433231e26d5930a2ff8d737f424e61 (diff) | |
download | zsh-606cfb5a5e65c80d88fc90169200cea404c16796.tar.gz zsh-606cfb5a5e65c80d88fc90169200cea404c16796.tar.xz zsh-606cfb5a5e65c80d88fc90169200cea404c16796.zip |
27167: add POSIX_CD option to test "." after CDPATH
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | Doc/Zsh/builtins.yo | 3 | ||||
-rw-r--r-- | Doc/Zsh/options.yo | 16 | ||||
-rw-r--r-- | Src/builtin.c | 28 | ||||
-rw-r--r-- | Src/options.c | 1 | ||||
-rw-r--r-- | Src/zsh.h | 1 |
6 files changed, 51 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog index ccfd93a33..2dc28a2cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-07-19 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 27167: Src/builtin.c, Src/options.c, Src/zsh.h, + Doc/Zsh/builtins.yo, Doc/Zsh/options.yo: POSIX_CD option, + currently only moves testing of "." to after testing of CDPATH. + 2009-07-18 Clint Adams <clint@zsh.org> * 27160: Completion/Debian/Command/_bug: tweaks to reportbug @@ -12005,5 +12011,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.4744 $ +* $Revision: 1.4745 $ ***************************************************** diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index bf12a3384..4311e871e 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -183,6 +183,9 @@ to the directory var(arg) under each component of tt(cdpath) in turn until 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 diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index 74b5c8f86..8629a0718 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -115,6 +115,22 @@ This also has the effect of tt(CHASE_DOTS), i.e. a `tt(..)' path segment 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) diff --git a/Src/builtin.c b/Src/builtin.c index 162e7c254..dc39b2a7f 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -945,14 +945,23 @@ cd_do_chdir(char *cnam, char *dest, int hard) 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 @@ cd_do_chdir(char *cnam, char *dest, int hard) 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))) { diff --git a/Src/options.c b/Src/options.c index 8e5308c0b..c5b7c3b8f 100644 --- a/Src/options.c +++ b/Src/options.c @@ -200,6 +200,7 @@ static struct optname optns[] = { {{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}, diff --git a/Src/zsh.h b/Src/zsh.h index a230a5058..060f8a6d4 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1966,6 +1966,7 @@ enum { PATHDIRS, POSIXALIASES, POSIXBUILTINS, + POSIXCD, POSIXIDENTIFIERS, POSIXJOBS, PRINTEIGHTBIT, |