summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-06-13 10:17:36 +0000
committerJim Meyering <jim@meyering.net>2005-06-13 10:17:36 +0000
commit4063f9696ce3402f8ebcff6ac4f95f861c4a7d4d (patch)
tree6281b40c48b2f0bc89ba3305a2373888a3c5aece /src
parentecd375b64aeb3805261916ee3408fadcacd0c448 (diff)
downloadcoreutils-4063f9696ce3402f8ebcff6ac4f95f861c4a7d4d.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.
Diffstat (limited to 'src')
-rw-r--r--src/mkdir.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mkdir.c b/src/mkdir.c
index a2307bcd2..3ba3d7a6a 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -87,6 +87,7 @@ main (int argc, char **argv)
const char *verbose_fmt_string = NULL;
int exit_status = EXIT_SUCCESS;
int optc;
+ bool cwd_not_restored;
initialize_main (&argc, &argv);
program_name = argv[0];
@@ -145,15 +146,29 @@ main (int argc, char **argv)
umask (umask_value);
}
+ /* FIXME: when we assume C99, declare this here. */
+ cwd_not_restored = false;
for (; optind < argc; ++optind)
{
bool ok;
+ 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]));
+ exit_status = EXIT_FAILURE;
+ continue;
+ }
+
if (create_parents)
{
+ bool different_cwd;
char *dir = argv[optind];
ok = make_dir_parents (dir, newmode, parent_mode,
- -1, -1, true, verbose_fmt_string);
+ -1, -1, true, verbose_fmt_string,
+ &different_cwd);
+ cwd_not_restored |= different_cwd;
}
else
{