diff options
author | dg <dg@FreeBSD.org> | 1994-08-12 07:26:52 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1994-08-12 07:26:52 +0000 |
commit | 679aa902928d20d002ff66fbba075b6fcae551c4 (patch) | |
tree | f15270f28e3087224497ec72aa3fc2152d2e35c2 /usr.bin/du/du.c | |
parent | cc490038a0f6ece1aa559fbd7f0f2ff39eecbf5a (diff) | |
download | FreeBSD-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/du.c')
-rw-r--r-- | usr.bin/du/du.c | 13 |
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(¬used, &blocksize); + if (oldbsize) + putenv(oldbsize); blocksize /= 512; if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL) |