summaryrefslogtreecommitdiffstats
path: root/usr.bin/du
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1994-08-12 07:26:52 +0000
committerdg <dg@FreeBSD.org>1994-08-12 07:26:52 +0000
commit679aa902928d20d002ff66fbba075b6fcae551c4 (patch)
treef15270f28e3087224497ec72aa3fc2152d2e35c2 /usr.bin/du
parentcc490038a0f6ece1aa559fbd7f0f2ff39eecbf5a (diff)
downloadFreeBSD-src-679aa902928d20d002ff66fbba075b6fcae551c4.zip
FreeBSD-src-679aa902928d20d002ff66fbba075b6fcae551c4.tar.gz
Implemented the -k flag more properly...don't destroy the user's setting
of the BLOCKSIZE environment variable.
Diffstat (limited to 'usr.bin/du')
-rw-r--r--usr.bin/du/du.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c
index 49b5f9b..2cae7e8 100644
--- a/usr.bin/du/du.c
+++ b/usr.bin/du/du.c
@@ -66,12 +66,13 @@ main(argc, argv)
FTS *fts;
FTSENT *p;
long blocksize;
+ char *oldbsize = NULL;
int ftsoptions, listdirs, listfiles;
- int Hflag, Lflag, Pflag, aflag, ch, notused, rval, sflag;
+ int Hflag, Lflag, Pflag, aflag, ch, notused, rval, sflag, kflag;
char **save;
save = argv;
- Hflag = Lflag = Pflag = aflag = sflag = 0;
+ Hflag = Lflag = Pflag = aflag = sflag = kflag = 0;
ftsoptions = FTS_PHYSICAL;
while ((ch = getopt(argc, argv, "HLPaksx")) != EOF)
switch (ch) {
@@ -91,7 +92,7 @@ main(argc, argv)
aflag = 1;
break;
case 'k':
- putenv("BLOCKSIZE=1024");
+ kflag = 1;
break;
case 's':
sflag = 1;
@@ -142,7 +143,13 @@ main(argc, argv)
argv[1] = NULL;
}
+ if (kflag) {
+ oldbsize = getenv("BLOCKSIZE");
+ putenv("BLOCKSIZE=1k");
+ }
(void)getbsize(&notused, &blocksize);
+ if (oldbsize)
+ putenv(oldbsize);
blocksize /= 512;
if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
OpenPOWER on IntegriCloud