chmod: Add -HLP flags and update manpage
This commit is contained in:
parent
1d05b293e1
commit
9da1deaab9
21
chmod.1
21
chmod.1
@ -6,9 +6,12 @@
|
|||||||
.Nd change file mode
|
.Nd change file mode
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl R
|
.Oo
|
||||||
|
.Fl R
|
||||||
|
.Op Fl H | L | P
|
||||||
|
.Oc
|
||||||
.Ar mode
|
.Ar mode
|
||||||
.Op Ar file ...
|
.Ar file ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
changes the file mode of the given
|
changes the file mode of the given
|
||||||
@ -54,9 +57,17 @@ read | write | execute | setuid and setgid | sticky
|
|||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl R
|
.It Fl R
|
||||||
Change modes recursively
|
Change modes recursively.
|
||||||
|
.It Fl H
|
||||||
|
Only dereference symbolic links that are passed as command line arguments when
|
||||||
|
recursively traversing directories.
|
||||||
|
.It Fl L
|
||||||
|
Always dereference symbolic links while recursively traversing directories.
|
||||||
|
.It Fl P
|
||||||
|
Don't dereference symbolic links (default).
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
|
.Xr chgrp 1 ,
|
||||||
.Xr umask 1
|
.Xr umask 1
|
||||||
.Sh STANDARDS
|
.Sh STANDARDS
|
||||||
The
|
The
|
||||||
@ -66,5 +77,5 @@ utility is compliant with the
|
|||||||
specification.
|
specification.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Op Fl R
|
.Op Fl HLP
|
||||||
flag is an extension to that specification.
|
flags are an extension to that specification.
|
||||||
|
16
chmod.c
16
chmod.c
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static int rflag = 0;
|
static int Rflag = 0;
|
||||||
|
static int fflag = 'P';
|
||||||
static char *modestr = "";
|
static char *modestr = "";
|
||||||
static mode_t mask = 0;
|
static mode_t mask = 0;
|
||||||
static int ret = 0;
|
static int ret = 0;
|
||||||
@ -25,14 +26,14 @@ chmodr(const char *path, int fflag)
|
|||||||
weprintf("chmod %s:", path);
|
weprintf("chmod %s:", path);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
if (rflag)
|
if (Rflag)
|
||||||
recurse(path, chmodr, fflag);
|
recurse(path, chmodr, fflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-R] mode [file ...]\n", argv0);
|
eprintf("usage: %s [-R [-H | -L | -P]] mode file ...\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -44,7 +45,12 @@ main(int argc, char *argv[])
|
|||||||
for (i = 1; i < argc && argv[i][0] == '-'; i++) {
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) {
|
||||||
switch (argv[i][1]) {
|
switch (argv[i][1]) {
|
||||||
case 'R':
|
case 'R':
|
||||||
rflag = 1;
|
Rflag = 1;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
case 'L':
|
||||||
|
case 'P':
|
||||||
|
fflag = argv[i][1];
|
||||||
break;
|
break;
|
||||||
case 'r': case 'w': case 'x': case 's': case 't':
|
case 'r': case 'w': case 'x': case 's': case 't':
|
||||||
/*
|
/*
|
||||||
@ -65,7 +71,7 @@ done:
|
|||||||
usage();
|
usage();
|
||||||
|
|
||||||
for (++i; i < argc; i++)
|
for (++i; i < argc; i++)
|
||||||
chmodr(argv[i], 'P');
|
chmodr(argv[i], fflag);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user