From owner-svn-src-stable@FreeBSD.ORG Wed Jan 11 23:30:19 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 673D9106566C; Wed, 11 Jan 2012 23:30:19 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3A9698FC13; Wed, 11 Jan 2012 23:30:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0BNUJsJ081755; Wed, 11 Jan 2012 23:30:19 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0BNUJVO081752; Wed, 11 Jan 2012 23:30:19 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201201112330.q0BNUJVO081752@svn.freebsd.org> From: Jilles Tjoelker Date: Wed, 11 Jan 2012 23:30:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229992 - stable/9/usr.bin/du X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 23:30:19 -0000 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;