summaryrefslogtreecommitdiff
path: root/symlinks.c
diff options
context:
space:
mode:
Diffstat (limited to 'symlinks.c')
-rw-r--r--symlinks.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/symlinks.c b/symlinks.c
index 5232d02020..c667baa949 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -279,7 +279,9 @@ static void do_remove_scheduled_dirs(int new_len)
{
while (removal.len > new_len) {
removal.buf[removal.len] = '\0';
- if (rmdir(removal.buf))
+ if ((startup_info->original_cwd &&
+ !strcmp(removal.buf, startup_info->original_cwd)) ||
+ rmdir(removal.buf))
break;
do {
removal.len--;
@@ -293,6 +295,10 @@ void schedule_dir_for_removal(const char *name, int len)
{
int match_len, last_slash, i, previous_slash;
+ if (startup_info->original_cwd &&
+ !strcmp(name, startup_info->original_cwd))
+ return; /* Do not remove the current working directory */
+
match_len = last_slash = i =
longest_path_match(name, len, removal.buf, removal.len,
&previous_slash);