[hackers] [sbase] Add -k support for du(1) || sin

From: <git_AT_suckless.org>
Date: Wed, 16 Oct 2013 20:22:59 +0200

commit ac3a5e0091c74d9ae4e19d3dc8fac83a1b91caf0
Author: sin <sin_AT_2f30.org>
Date: Wed Oct 16 18:00:02 2013 +0100

    Add -k support for du(1)
    
    This setting overrides the BLOCKSIZE environment variable.

diff --git a/du.1 b/du.1
index 932e693..3320c8b 100644
--- a/du.1
+++ b/du.1
_AT_@ -19,3 +19,7 @@ Display an entry for each file in the file hierarchy.
 .TP
 .BI \-s
 Display only the grand total for the specified files.
+.TP
+.BI \-k
+By default all sizes are reported in 512-byte block counts.
+The -k option causes the numbers to be reported in kilobyte counts.
diff --git a/du.c b/du.c
index 3c6461b..4b3ebb0 100644
--- a/du.c
+++ b/du.c
_AT_@ -15,6 +15,7 @@ static long blksize = 512;
 
 static bool aflag = false;
 static bool sflag = false;
+static bool kflag = false;
 
 static long du(const char *);
 static void print(long n, char *path);
_AT_@ -38,6 +39,9 @@ main(int argc, char *argv[])
         case 's':
                 sflag = true;
                 break;
+ case 'k':
+ kflag = true;
+ break;
         default:
                 usage();
         } ARGEND;
_AT_@ -46,6 +50,9 @@ main(int argc, char *argv[])
         if (bsize)
                 blksize = estrtol(bsize, 0);
 
+ if (kflag)
+ blksize = 1024;
+
         if (argc < 1) {
                 n = du(".");
                 if (sflag)
Received on Wed Oct 16 2013 - 20:22:59 CEST

This archive was generated by hypermail 2.3.0 : Wed Oct 16 2013 - 20:24:23 CEST