add verbose flag
Reviewed by: obrien
This commit is contained in:
parent
ca66889cf7
commit
1df89a603d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=50528
@ -45,6 +45,7 @@
|
|||||||
.Nm mkdir
|
.Nm mkdir
|
||||||
.Op Fl p
|
.Op Fl p
|
||||||
.Op Fl m Ar mode
|
.Op Fl m Ar mode
|
||||||
|
.Op Fl v
|
||||||
.Ar directory_name ...
|
.Ar directory_name ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm Mkdir
|
.Nm Mkdir
|
||||||
@ -77,6 +78,8 @@ Intermediate directories are created with permission bits of
|
|||||||
.Li rwxrwxrwx (\&0777)
|
.Li rwxrwxrwx (\&0777)
|
||||||
as modified by the current umask, plus write and search
|
as modified by the current umask, plus write and search
|
||||||
permission for the owner.
|
permission for the owner.
|
||||||
|
.It Fl p
|
||||||
|
Be verbose when creating directories, listing them as they are created.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The user must have write permission in the parent directory.
|
The user must have write permission in the parent directory.
|
||||||
|
@ -53,11 +53,14 @@ static const char rcsid[] =
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sysexits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int build __P((char *, mode_t));
|
int build __P((char *, mode_t));
|
||||||
void usage __P((void));
|
void usage __P((void));
|
||||||
|
|
||||||
|
int vflag;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -69,11 +72,14 @@ main(argc, argv)
|
|||||||
|
|
||||||
omode = pflag = 0;
|
omode = pflag = 0;
|
||||||
mode = NULL;
|
mode = NULL;
|
||||||
while ((ch = getopt(argc, argv, "m:p")) != -1)
|
while ((ch = getopt(argc, argv, "m:pv")) != -1)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'p':
|
case 'p':
|
||||||
pflag = 1;
|
pflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
vflag = 1;
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
mode = optarg;
|
mode = optarg;
|
||||||
break;
|
break;
|
||||||
@ -104,7 +110,9 @@ main(argc, argv)
|
|||||||
} else if (mkdir(*argv, omode) < 0) {
|
} else if (mkdir(*argv, omode) < 0) {
|
||||||
warn("%s", *argv);
|
warn("%s", *argv);
|
||||||
success = 0;
|
success = 0;
|
||||||
}
|
} else if (vflag)
|
||||||
|
(void)printf("%s\n", *argv);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
exitval = 1;
|
exitval = 1;
|
||||||
/*
|
/*
|
||||||
@ -172,7 +180,8 @@ build(path, omode)
|
|||||||
warn("%s", path);
|
warn("%s", path);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
break;
|
break;
|
||||||
}
|
} else if (vflag)
|
||||||
|
printf("%s\n", path);
|
||||||
}
|
}
|
||||||
else if ((sb.st_mode & S_IFMT) != S_IFDIR) {
|
else if ((sb.st_mode & S_IFMT) != S_IFDIR) {
|
||||||
if (last)
|
if (last)
|
||||||
@ -194,6 +203,6 @@ build(path, omode)
|
|||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage: mkdir [-p] [-m mode] directory ...\n");
|
(void)fprintf(stderr, "usage: mkdir [-p] [-m mode] [-v] directory ...\n");
|
||||||
exit (1);
|
exit (EX_USAGE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user