commit 6c31f1d2a8d02bd038a5af45a45c53e346aaba9b
parent e5b54977734030067adc7d17352a2a90563d4833
Author: sin <sin@2f30.org>
Date: Tue, 17 Feb 2015 16:07:10 +0000
du: Update usage and document -P as well
Diffstat:
M | du.1 | | | 21 | +++++++++++---------- |
M | du.c | | | 11 | ++++++----- |
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/du.1 b/du.1
@@ -1,4 +1,4 @@
-.Dd January 30, 2015
+.Dd February 17, 2015
.Dt DU 1
.Os sbase
.Sh NAME
@@ -8,10 +8,9 @@
.Nm
.Op Fl a | s
.Op Fl d Ar depth
-.Op Fl H
-.Op Fl L
.Op Fl h
.Op Fl k
+.Op Fl H | L | P
.Op Ar file ...
.Sh DESCRIPTION
.Nm
@@ -26,13 +25,10 @@ is displayed.
.Bl -tag -width Ds
.It Fl a
Display an entry for each file in the file hierarchy.
+.It Fl s
+Display only the grand total for the specified files.
.It Fl d Ar depth
Maximum directory depth to print files and directories.
-.It Fl H
-Only dereference symbolic links that are passed as command line arguments when
-recursively traversing directories.
-.It Fl L
-Always dereference symbolic links while recursively traversing directories.
.It Fl h
Enable human-readable output.
.It Fl k
@@ -40,6 +36,11 @@ By default all sizes are reported in 512-byte block counts.
The
.Fl k
option causes the numbers to be reported in kilobyte counts.
-.It Fl s
-Display only the grand total for the specified files.
+.It Fl H
+Only dereference symbolic links that are passed as command line arguments when
+recursively traversing directories.
+.It Fl L
+Always dereference symbolic links while recursively traversing directories.
+.It FL P
+Don't dereference symbolic links. This is the default.
.El
diff --git a/du.c b/du.c
@@ -21,7 +21,7 @@ static int dflag = 0;
static int sflag = 0;
static int kflag = 0;
static int hflag = 0;
-static int HLflag = 'P';
+static int HLPflag = 'P';
static char *
xrealpath(const char *pathname, char *resolved)
@@ -138,7 +138,7 @@ done:
static void
usage(void)
{
- eprintf("usage: %s [-a | -s] [-d depth] [-h] [-k] [file ...]\n", argv0);
+ eprintf("usage: %s [-a | -s] [-d depth] [-h] [-k] [-H | -L | -P] [file ...]\n", argv0);
}
int
@@ -166,7 +166,8 @@ main(int argc, char *argv[])
break;
case 'H':
case 'L':
- HLflag = ARGC();
+ case 'P':
+ HLPflag = ARGC();
break;
default:
usage();
@@ -183,13 +184,13 @@ main(int argc, char *argv[])
blksize = 1024;
if (argc < 1) {
- n = du(".", HLflag);
+ n = du(".", HLPflag);
if (sflag)
print(n, xrealpath(".", file));
} else {
for (; argc > 0; argc--, argv++) {
curdepth = 0;
- n = du(argv[0], HLflag);
+ n = du(argv[0], HLPflag);
if (sflag)
print(n, xrealpath(argv[0], file));
}