diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-03-20 22:52:56 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-03-20 22:52:56 +0000 |
commit | 28a809886d3df86ffb07c302ff717b621caf22a2 (patch) | |
tree | ea96b6c4b49327e567cdd521f929a517135839a1 | |
parent | 249148d765d846f35d9e3805a89f978892c74208 (diff) | |
download | zsh-28a809886d3df86ffb07c302ff717b621caf22a2.tar.gz zsh-28a809886d3df86ffb07c302ff717b621caf22a2.tar.xz zsh-28a809886d3df86ffb07c302ff717b621caf22a2.zip |
26763: fix problem on failed cd -s to relative path
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/utils.c | 11 | ||||
-rw-r--r-- | Test/B01cd.ztst | 8 |
3 files changed, 18 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog index 0d2254e5a..38d0a21d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-03-20 Peter Stephenson <p.w.stephenson@ntlworld.com> + * 26763: Src/utils.c: fix problem restoring directory + when attempting to cd to relative path and failing. + * users/13593: Src/utils.c: tidy up from 26625. 2009-03-20 Peter Stephenson <pws@csr.com> @@ -11462,5 +11465,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.4629 $ +* $Revision: 1.4630 $ ***************************************************** diff --git a/Src/utils.c b/Src/utils.c index e66d5bbf9..9716e162c 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -5388,11 +5388,7 @@ lchdir(char const *path, struct dirsav *d, int hard) if (*path == '/') { #endif level = -1; -#ifdef HAVE_FCHDIR - if (d->dirfd < 0 && (d->dirfd = open(".", O_RDONLY | O_NOCTTY)) < 0 && - zgetdir(d) && *d->dirname != '/') - d->dirfd = open("..", O_RDONLY | O_NOCTTY); -#else +#ifndef HAVE_FCHDIR if (!d->dirname) zgetdir(d); #endif @@ -5404,6 +5400,11 @@ lchdir(char const *path, struct dirsav *d, int hard) d->ino = st1.st_ino; } } +#ifdef HAVE_FCHDIR + if (d->dirfd < 0 && (d->dirfd = open(".", O_RDONLY | O_NOCTTY)) < 0 && + zgetdir(d) && *d->dirname != '/') + d->dirfd = open("..", O_RDONLY | O_NOCTTY); +#endif #ifdef HAVE_LSTAT if (!hard) diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst index 1995971cf..b5ba4d03b 100644 --- a/Test/B01cd.ztst +++ b/Test/B01cd.ztst @@ -109,6 +109,14 @@ F:something is broken. But you already knew that. >$mydir/cdtst.tmp/real >$mydir/cdtst.tmp/real + ln -s nonexistent link_to_nonexistent + pwd1=$(pwd -P) + cd -s link_to_nonexistent + pwd2=$(pwd -P) + [[ $pwd1 = $pwd2 ]] || print "Ooops, changed to directory '$pwd2'" +0: +?(eval):cd:3: not a directory: link_to_nonexistent + %clean # This optional section cleans up after the test, if necessary, # e.g. killing processes etc. This is in addition to the removal of *.tmp |