diff options
author | Jim Meyering <jim@meyering.net> | 2005-06-13 10:19:18 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-06-13 10:19:18 +0000 |
commit | 736dfd391dbcdba2340ded3066a186ec6c7be1b4 (patch) | |
tree | 056c5f4e61cad2fcd925b7b1358f2bbd44e53110 /src/install.c | |
parent | 4063f9696ce3402f8ebcff6ac4f95f861c4a7d4d (diff) | |
download | coreutils-736dfd391dbcdba2340ded3066a186ec6c7be1b4.tar.xz |
(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.
Diffstat (limited to 'src/install.c')
-rw-r--r-- | src/install.c | 21 |
1 files changed, 19 insertions, 2 deletions
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); |