From c659704b20c712a1e65c26755a7c24f224179930 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 13 Apr 1996 03:59:20 +0000 Subject: [PATCH] (main): Add new option: --verbose. Remove long-deprecated and nowhere-documented --path, a synonym for --parents. It was confusing to get an error about `--p' being ambiguous. --- src/mkdir.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mkdir.c b/src/mkdir.c index ac4a280..91248bc 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -52,9 +52,9 @@ static int show_version; static struct option const longopts[] = { {"mode", required_argument, NULL, 'm'}, - {"path", no_argument, &path_mode, 1}, {"parents", no_argument, &path_mode, 1}, {"help", no_argument, &show_help, 1}, + {"verbose", no_argument, NULL, 2}, {"version", no_argument, &show_version, 1}, {NULL, 0, NULL, 0} }; @@ -73,6 +73,7 @@ Create the DIRECTORY(ies), if they do not already exist.\n\ \n\ -p, --parents no error if existing, make parent directories as needed\n\ -m, --mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask\n\ + --verbose print a message for each created directory\n\ --help display this help and exit\n\ --version output version information and exit\n")); } @@ -85,6 +86,7 @@ main (int argc, char **argv) unsigned int newmode; unsigned int parent_mode; char *symbolic_mode = NULL; + const char *verbose_fmt_string = NULL; int errors = 0; int optc; @@ -107,6 +109,9 @@ main (int argc, char **argv) case 'm': symbolic_mode = optarg; break; + case 2: /* --verbose */ + verbose_fmt_string = _("created directory `%s'"); + break; default: usage (1); } @@ -144,13 +149,17 @@ main (int argc, char **argv) if (path_mode) { errors |= make_path (argv[optind], newmode, parent_mode, - -1, -1, 1, NULL); + -1, -1, 1, _("created directory `%s'")); } else if (mkdir (argv[optind], newmode)) { error (0, errno, _("cannot make directory `%s'"), argv[optind]); errors = 1; } + else if (verbose_fmt_string) + { + error (0, 0, verbose_fmt_string, argv[optind]); + } } exit (errors); -- 2.7.4