chgrp: Update program usage and manpage
-h is incompatible with -R so handle that properly as well.
This commit is contained in:
		
							
								
								
									
										19
									
								
								chgrp.1
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								chgrp.1
									
									
									
									
									
								
							@@ -6,12 +6,13 @@
 | 
			
		||||
.Nd change the file group ownership
 | 
			
		||||
.Sh SYNOPSIS
 | 
			
		||||
.Nm
 | 
			
		||||
.Op Fl R
 | 
			
		||||
.Op Fl H
 | 
			
		||||
.Op Fl L
 | 
			
		||||
.Op Fl P
 | 
			
		||||
.Ar groupname
 | 
			
		||||
.Op Ar file...
 | 
			
		||||
.Op Fl h
 | 
			
		||||
.Oo
 | 
			
		||||
.Fl R
 | 
			
		||||
.Op Fl H | L | P
 | 
			
		||||
.Oc
 | 
			
		||||
.Ar group
 | 
			
		||||
.Ar file...
 | 
			
		||||
.Sh DESCRIPTION
 | 
			
		||||
.Nm
 | 
			
		||||
sets the group id of the files specified by
 | 
			
		||||
@@ -20,6 +21,10 @@ to the gid of the group named
 | 
			
		||||
.Ar group .
 | 
			
		||||
.Sh OPTIONS
 | 
			
		||||
.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
 | 
			
		||||
Change file group ownership recursively.
 | 
			
		||||
.It Fl H
 | 
			
		||||
@@ -42,4 +47,4 @@ The
 | 
			
		||||
.Nm
 | 
			
		||||
utility is compliant with the
 | 
			
		||||
.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 status;
 | 
			
		||||
static int rflag;
 | 
			
		||||
static int Rflag;
 | 
			
		||||
static int fflag = 'P';
 | 
			
		||||
static struct stat st;
 | 
			
		||||
static char *chown_f_name = "chown";
 | 
			
		||||
@@ -22,14 +22,14 @@ chgrp(const char *path, int fflag)
 | 
			
		||||
		weprintf("%s %s:", chown_f_name, path);
 | 
			
		||||
		status = 1;
 | 
			
		||||
	}
 | 
			
		||||
	if (rflag)
 | 
			
		||||
	if (Rflag)
 | 
			
		||||
		recurse(path, chgrp, fflag);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
usage(void)
 | 
			
		||||
{
 | 
			
		||||
	eprintf("usage: chgrp [-hR] groupname file...\n");
 | 
			
		||||
	eprintf("usage: chgrp [-h] [-R [-H | -L | -P]] group file ...\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
@@ -43,7 +43,7 @@ main(int argc, char *argv[])
 | 
			
		||||
		chown_f = lchown;
 | 
			
		||||
		break;
 | 
			
		||||
	case 'R':
 | 
			
		||||
		rflag = 1;
 | 
			
		||||
		Rflag = 1;
 | 
			
		||||
		break;
 | 
			
		||||
	case 'H':
 | 
			
		||||
	case 'L':
 | 
			
		||||
@@ -54,7 +54,7 @@ main(int argc, char *argv[])
 | 
			
		||||
		usage();
 | 
			
		||||
	} ARGEND;
 | 
			
		||||
 | 
			
		||||
	if (argc < 2)
 | 
			
		||||
	if (argc < 2 || (chown_f == lchown && Rflag))
 | 
			
		||||
		usage();
 | 
			
		||||
 | 
			
		||||
	errno = 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user