svn commit: r229992 - stable/9/usr.bin/du
Jilles Tjoelker
jilles at FreeBSD.org
Wed Jan 11 23:30:19 UTC 2012
Author: jilles
Date: Wed Jan 11 23:30:18 2012
New Revision: 229992
URL: http://svn.freebsd.org/changeset/base/229992
Log:
MFC r228669: 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).
Modified:
stable/9/usr.bin/du/du.1
stable/9/usr.bin/du/du.c
Directory Properties:
stable/9/usr.bin/du/ (props changed)
Modified: stable/9/usr.bin/du/du.1
==============================================================================
--- stable/9/usr.bin/du/du.1 Wed Jan 11 23:11:48 2012 (r229991)
+++ stable/9/usr.bin/du/du.1 Wed Jan 11 23:30:18 2012 (r229992)
@@ -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: stable/9/usr.bin/du/du.c
==============================================================================
--- stable/9/usr.bin/du/du.c Wed Jan 11 23:11:48 2012 (r229991)
+++ stable/9/usr.bin/du/du.c Wed Jan 11 23:30:18 2012 (r229992)
@@ -90,18 +90,18 @@ main(int argc, char *argv[])
int ftsoptions;
int listall;
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;
@@ -126,19 +126,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;
@@ -211,20 +209,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;
More information about the svn-src-stable-9
mailing list