From 736dfd391dbcdba2340ded3066a186ec6c7be1b4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 13 Jun 2005 10:19:18 +0000 Subject: (main): When make_dir_parents changes the current working directory, give a diagnostic about each subsequent failure to create a dot-relative directory. (install_file_in_file_parents): Update make_dir_parents caller. --- src/install.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/install.c') diff --git a/src/install.c b/src/install.c index 027d201d9..b885fae86 100644 --- a/src/install.c +++ b/src/install.c @@ -357,11 +357,25 @@ main (int argc, char **argv) if (dir_arg) { int i; + bool cwd_not_restored = false; for (i = 0; i < n_files; i++) { + bool different_cwd; + if (cwd_not_restored && IS_RELATIVE_FILE_NAME (argv[optind])) + { + error (0, 0, + _("unable to create relative-named directory, %s," + " due to prior failure to restore working directory"), + quote (argv[optind])); + ok = false;; + continue; + } + ok &= make_dir_parents (file[i], mode, mode, owner_id, group_id, false, - (x.verbose ? _("creating directory %s") : NULL)); + (x.verbose ? _("creating directory %s") : NULL), + &different_cwd); + cwd_not_restored |= different_cwd; } } else @@ -409,9 +423,12 @@ install_file_in_file_parents (char const *from, char const *to, that this option is intended mainly to help installers when the distribution doesn't provide proper install rules. */ mode_t dir_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + bool different_cwd; /* FIXME: use this */ ok = make_dir_parents (dest_dir, dir_mode, dir_mode, owner_id, group_id, true, - (x->verbose ? _("creating directory %s") : NULL)); + (x->verbose ? _("creating directory %s") : NULL), + &different_cwd); + /* Ignore different_cwd, since this function is called at most once. */ } free (dest_dir); -- cgit v1.2.3-54-g00ecf