add verbose flag

Reviewed by:	obrien
This commit is contained in:
Michael Haro 1999-08-28 20:46:00 +00:00
parent ca66889cf7
commit 1df89a603d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=50528
2 changed files with 17 additions and 5 deletions

View File

@ -45,6 +45,7 @@
.Nm mkdir
.Op Fl p
.Op Fl m Ar mode
.Op Fl v
.Ar directory_name ...
.Sh DESCRIPTION
.Nm Mkdir
@ -77,6 +78,8 @@ Intermediate directories are created with permission bits of
.Li rwxrwxrwx (\&0777)
as modified by the current umask, plus write and search
permission for the owner.
.It Fl p
Be verbose when creating directories, listing them as they are created.
.El
.Pp
The user must have write permission in the parent directory.

View File

@ -53,11 +53,14 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
int build __P((char *, mode_t));
void usage __P((void));
int vflag;
int
main(argc, argv)
int argc;
@ -69,11 +72,14 @@ main(argc, argv)
omode = pflag = 0;
mode = NULL;
while ((ch = getopt(argc, argv, "m:p")) != -1)
while ((ch = getopt(argc, argv, "m:pv")) != -1)
switch(ch) {
case 'p':
pflag = 1;
break;
case 'v':
vflag = 1;
break;
case 'm':
mode = optarg;
break;
@ -104,7 +110,9 @@ main(argc, argv)
} else if (mkdir(*argv, omode) < 0) {
warn("%s", *argv);
success = 0;
}
} else if (vflag)
(void)printf("%s\n", *argv);
if (!success)
exitval = 1;
/*
@ -172,7 +180,8 @@ build(path, omode)
warn("%s", path);
retval = 1;
break;
}
} else if (vflag)
printf("%s\n", path);
}
else if ((sb.st_mode & S_IFMT) != S_IFDIR) {
if (last)
@ -194,6 +203,6 @@ build(path, omode)
void
usage()
{
(void)fprintf(stderr, "usage: mkdir [-p] [-m mode] directory ...\n");
exit (1);
(void)fprintf(stderr, "usage: mkdir [-p] [-m mode] [-v] directory ...\n");
exit (EX_USAGE);
}