I found it a little confusing that the order of the options for df 
can make a difference in the output. For example:

[/usr/src/bin/df] df -hk .
Filesystem  1K-blocks      Used     Avail Capacity  Mounted on
/dev/sd0a   472403466 316700726 132082568    71%    /

[/usr/src/bin/df] df -kh . 
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd0a      451G    302G    126G    71%    /

With the patch below you get the same result in both cases.

[/usr/src/bin/df] df -hk .
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd0a      451G    302G    126G    71%    /

[/usr/src/bin/df] df -kh . 
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd0a      451G    302G    126G    71%    /


Index: df.c
===================================================================
RCS file: /cvs/src/bin/df/df.c,v
retrieving revision 1.49
diff -u -r1.49 df.c
--- df.c        16 Mar 2008 20:04:35 -0000      1.49
+++ df.c        14 May 2009 03:53:31 -0000
@@ -98,14 +98,12 @@
                switch (ch) {
                case 'h':
                        hflag = 1;
-                       kflag = 0;
                        break;
                case 'i':
                        iflag = 1;
                        break;
                case 'k':
                        kflag = 1;
-                       hflag = 0;
                        break;
                case 'l':
                        lflag = 1;
@@ -130,6 +128,10 @@
        if ((iflag || hflag) && Pflag) {
                warnx("-h and -i are incompatible with -P");
                usage();
+       }
+
+       if (hflag && kflag) {
+               kflag = 0;
        }
 
        mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);

Reply via email to