Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Dec 2011 23:18:14 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r228669 - head/usr.bin/du
Message-ID:  <201112172318.pBHNIEkl081035@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sat Dec 17 23:18:14 2011
New Revision: 228669
URL: http://svn.freebsd.org/changeset/base/228669

Log:
  du: Allow multiple -HLP options, the last one wins.
  
  This matches 4.4BSD tradition and other utilities with these options and is
  required by POSIX (POSIX does not specify -P, only -HL).
  
  MFC after:	2 weeks

Modified:
  head/usr.bin/du/du.1
  head/usr.bin/du/du.c

Modified: head/usr.bin/du/du.1
==============================================================================
--- head/usr.bin/du/du.1	Sat Dec 17 22:32:00 2011	(r228668)
+++ head/usr.bin/du/du.1	Sat Dec 17 23:18:14 2011	(r228669)
@@ -28,7 +28,7 @@
 .\"	@(#)du.1	8.2 (Berkeley) 4/1/94
 .\" $FreeBSD$
 .\"
-.Dd December 8, 2011
+.Dd December 17, 2011
 .Dt DU 1
 .Os
 .Sh NAME
@@ -155,6 +155,13 @@ or
 .Fl L
 option is specified, storage used by any symbolic links which are
 followed is not counted (or displayed).
+The
+.Fl H ,
+.Fl L
+and
+.Fl P
+options override each other and the command's actions are determined
+by the last one specified.
 .Pp
 The
 .Fl h, k

Modified: head/usr.bin/du/du.c
==============================================================================
--- head/usr.bin/du/du.c	Sat Dec 17 22:32:00 2011	(r228668)
+++ head/usr.bin/du/du.c	Sat Dec 17 23:18:14 2011	(r228669)
@@ -89,18 +89,18 @@ main(int argc, char *argv[])
 	off_t		threshold, threshold_sign;
 	int		ftsoptions;
 	int		depth;
-	int		Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag;
+	int		Hflag, Lflag, aflag, sflag, dflag, cflag;
 	int		hflag, lflag, ch, notused, rval;
 	char 		**save;
 	static char	dot[] = ".";
 
 	setlocale(LC_ALL, "");
 
-	Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag =
+	Hflag = Lflag = aflag = sflag = dflag = cflag = hflag =
 	    lflag = Aflag = 0;
 
 	save = argv;
-	ftsoptions = 0;
+	ftsoptions = FTS_PHYSICAL;
 	savednumber = 0;
 	threshold = 0;
 	threshold_sign = 1;
@@ -125,19 +125,17 @@ main(int argc, char *argv[])
 			break;
 		case 'H':
 			Hflag = 1;
+			Lflag = 0;
 			break;
 		case 'I':
 			ignoreadd(optarg);
 			break;
 		case 'L':
-			if (Pflag)
-				usage();
 			Lflag = 1;
+			Hflag = 0;
 			break;
 		case 'P':
-			if (Lflag)
-				usage();
-			Pflag = 1;
+			Hflag = Lflag = 0;
 			break;
 		case 'a':
 			aflag = 1;
@@ -210,20 +208,12 @@ main(int argc, char *argv[])
 	 * the man page, so it's a feature.
 	 */
 
-	if (Hflag + Lflag + Pflag > 1)
-		usage();
-
-	if (Hflag + Lflag + Pflag == 0)
-		Pflag = 1;			/* -P (physical) is default */
-
 	if (Hflag)
 		ftsoptions |= FTS_COMFOLLOW;
-
-	if (Lflag)
+	if (Lflag) {
+		ftsoptions &= ~FTS_PHYSICAL;
 		ftsoptions |= FTS_LOGICAL;
-
-	if (Pflag)
-		ftsoptions |= FTS_PHYSICAL;
+	}
 
 	if (!Aflag && (cblocksize % DEV_BSIZE) != 0)
 		cblocksize = howmany(cblocksize, DEV_BSIZE) * DEV_BSIZE;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112172318.pBHNIEkl081035>