mirror of
git://git.suckless.org/sbase
synced 2024-12-23 07:25:07 +00:00
chgrp: Update program usage and manpage
-h is incompatible with -R so handle that properly as well.
This commit is contained in:
parent
8f068589fb
commit
1d05b293e1
21
chgrp.1
21
chgrp.1
@ -6,20 +6,25 @@
|
|||||||
.Nd change the file group ownership
|
.Nd change the file group ownership
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl R
|
.Op Fl h
|
||||||
.Op Fl H
|
.Oo
|
||||||
.Op Fl L
|
.Fl R
|
||||||
.Op Fl P
|
.Op Fl H | L | P
|
||||||
.Ar groupname
|
.Oc
|
||||||
.Op Ar file...
|
.Ar group
|
||||||
|
.Ar file...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
sets the group id of the files specified by
|
sets the group id of the files specified by
|
||||||
.Ar file
|
.Ar file
|
||||||
to the gid of the group named
|
to the gid of the group named
|
||||||
.Ar group.
|
.Ar group .
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
|
.It Fl h
|
||||||
|
Change the group ID of the symlink itself. This flag cannot be used
|
||||||
|
with
|
||||||
|
.Op Fl R .
|
||||||
.It Fl R
|
.It Fl R
|
||||||
Change file group ownership recursively.
|
Change file group ownership recursively.
|
||||||
.It Fl H
|
.It Fl H
|
||||||
@ -42,4 +47,4 @@ The
|
|||||||
.Nm
|
.Nm
|
||||||
utility is compliant with the
|
utility is compliant with the
|
||||||
.St -p1003.1-2008
|
.St -p1003.1-2008
|
||||||
specification except from the -h flag.
|
specification.
|
||||||
|
10
chgrp.c
10
chgrp.c
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
static int gid;
|
static int gid;
|
||||||
static int status;
|
static int status;
|
||||||
static int rflag;
|
static int Rflag;
|
||||||
static int fflag = 'P';
|
static int fflag = 'P';
|
||||||
static struct stat st;
|
static struct stat st;
|
||||||
static char *chown_f_name = "chown";
|
static char *chown_f_name = "chown";
|
||||||
@ -22,14 +22,14 @@ chgrp(const char *path, int fflag)
|
|||||||
weprintf("%s %s:", chown_f_name, path);
|
weprintf("%s %s:", chown_f_name, path);
|
||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
if (rflag)
|
if (Rflag)
|
||||||
recurse(path, chgrp, fflag);
|
recurse(path, chgrp, fflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: chgrp [-hR] groupname file...\n");
|
eprintf("usage: chgrp [-h] [-R [-H | -L | -P]] group file ...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -43,7 +43,7 @@ main(int argc, char *argv[])
|
|||||||
chown_f = lchown;
|
chown_f = lchown;
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
rflag = 1;
|
Rflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'L':
|
case 'L':
|
||||||
@ -54,7 +54,7 @@ main(int argc, char *argv[])
|
|||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2 || (chown_f == lchown && Rflag))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user