From ed9eac3967ed88262293aa395744194f8be294b0 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 18 Dec 2013 10:20:16 -0600 Subject: Ashwini Sharma added -v, I tweaked it a bit and added a couple test suite entries. --- toys/posix/mkdir.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'toys') diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c index 202eaa79..00946389 100644 --- a/toys/posix/mkdir.c +++ b/toys/posix/mkdir.c @@ -4,17 +4,18 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/mkdir.html -USE_MKDIR(NEWTOY(mkdir, "<1pm:", TOYFLAG_BIN|TOYFLAG_UMASK)) +USE_MKDIR(NEWTOY(mkdir, "<1vpm:", TOYFLAG_BIN|TOYFLAG_UMASK)) config MKDIR bool "mkdir" default y help - usage: mkdir [-p] [-m mode] [dirname...] + usage: mkdir [-vp] [-m mode] [dirname...] Create one or more directories. + -m set permissions of directory to mode. -p make parent directories as needed. - -m set permissions of directory to mode. + -v verbose */ #define FOR_mkdir @@ -55,9 +56,11 @@ static int do_mkdir(char *dir) if (save == '/') mode |= 0300; else if (toys.optflags&FLAG_m) mode = TT.mode; - if (mkdir(dir, mode)<0 && (!(toys.optflags&FLAG_p) || errno != EEXIST)) - return 1; - + if (mkdir(dir, mode)) { + if (!(toys.optflags&FLAG_p) || errno != EEXIST) return 1; + } else if (toys.optflags&FLAG_v) + fprintf(stderr, "%s: created directory '%s'\n", toys.which->name, dir); + if (!(*s = save)) break; } -- cgit v1.2.3