diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-28 14:50:06 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-07-28 14:50:06 +0000 |
commit | 5bfb177670771c7e26cdb39e3dcebb056702b00a (patch) | |
tree | fbd67e28e06c3b8dbd48d80208d7db639dbd8ccb | |
parent | 02b3090917ed6c91b8c6931a5988b4540c4d3cd8 (diff) | |
download | coreutils-5bfb177670771c7e26cdb39e3dcebb056702b00a.tar.xz |
(remove_dir): If we can't save the state of the
working directory, pretend we started from "/", not ".".
This avoids a bug on hosts like Solaris that don't let you
remove the working directory.
-rw-r--r-- | src/remove.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/remove.c b/src/remove.c index 0845e51da..86f08fefd 100644 --- a/src/remove.c +++ b/src/remove.c @@ -1008,9 +1008,12 @@ remove_dir (Dirstack_state *ds, char const *dir, struct cwd_state **cwd_state, (*cwd_state)->saved_errno = errno; assert (errno != 0); - /* Pretend we started from ".". That is fine as long as there - is no requirement to return to the original working directory. */ - (*cwd_state)->saved_cwd.name = xstrdup ("."); + /* Pretend we started from "/". That is fine as long as there + is no requirement to return to the original working directory. + Use "/", not ".", so that we chdir out of a non-root target + directory before attempting to remove it: some hosts don't let + you remove a working directory. */ + (*cwd_state)->saved_cwd.name = xstrdup ("/"); } else (*cwd_state)->saved_errno = 0; |