I guess you're right. It seems like what df does currently is also
consistent with what posix says for a command like ls.

"Specifying more than one of the options in the following
mutually-exclusive pairs shall not be considered an error...
-t and -S. The last option specified in each pair shall determine the
output format."

Seems like I'll have to get over my confusion :-)

On Tue, Jun 2, 2009 at 12:50 AM, Alexander Hall <ha...@openbsd.org> wrote:
> I don't agree as this is the normal behaviour of most commands;
>
> ls -St
> ls -tS
>
> ls -l1
> ls -1l
>
> ntpd -sS
> ntpd -Ss
>
> etc, etc.
>
> /Alexander
>
> Daniel Dickman wrote:
>> 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 B 1K-blocks B  B  B Used B  B  Avail Capacity B Mounted on
>> /dev/sd0a B  472403466 316700726 132082568 B  B 71% B  B /
>>
>> [/usr/src/bin/df] df -kh .
>> Filesystem B  B  Size B  B Used B  Avail Capacity B Mounted on
>> /dev/sd0a B  B  B 451G B  B 302G B  B 126G B  B 71% B  B /
>>
>> With the patch below you get the same result in both cases.
>>
>> [/usr/src/bin/df] df -hk .
>> Filesystem B  B  Size B  B Used B  Avail Capacity B Mounted on
>> /dev/sd0a B  B  B 451G B  B 302G B  B 126G B  B 71% B  B /
>>
>> [/usr/src/bin/df] df -kh .
>> Filesystem B  B  Size B  B Used B  Avail Capacity B Mounted on
>> /dev/sd0a B  B  B 451G B  B 302G B  B 126G B  B 71% B  B /
>>
>>
>> Index: df.c
>> ===================================================================
>> RCS file: /cvs/src/bin/df/df.c,v
>> retrieving revision 1.49
>> diff -u -r1.49 df.c
>> --- df.c B  B  B 16 Mar 2008 20:04:35 -0000 B  B  B 1.49
>> +++ df.c B  B  B 14 May 2009 03:53:31 -0000
>> @@ -98,14 +98,12 @@
>> B  B  B  B  B  B  B  switch (ch) {
>> B  B  B  B  B  B  B  case 'h':
>> B  B  B  B  B  B  B  B  B  B  B  hflag = 1;
>> - B  B  B  B  B  B  B  B  B  B  kflag = 0;
>> B  B  B  B  B  B  B  B  B  B  B  break;
>> B  B  B  B  B  B  B  case 'i':
>> B  B  B  B  B  B  B  B  B  B  B  iflag = 1;
>> B  B  B  B  B  B  B  B  B  B  B  break;
>> B  B  B  B  B  B  B  case 'k':
>> B  B  B  B  B  B  B  B  B  B  B  kflag = 1;
>> - B  B  B  B  B  B  B  B  B  B  hflag = 0;
>> B  B  B  B  B  B  B  B  B  B  B  break;
>> B  B  B  B  B  B  B  case 'l':
>> B  B  B  B  B  B  B  B  B  B  B  lflag = 1;
>> @@ -130,6 +128,10 @@
>> B  B  B  if ((iflag || hflag) && Pflag) {
>> B  B  B  B  B  B  B  warnx("-h and -i are incompatible with -P");
>> B  B  B  B  B  B  B  usage();
>> + B  B  }
>> +
>> + B  B  if (hflag && kflag) {
>> + B  B  B  B  B  B  kflag = 0;
>> B  B  B  }
>>
>> B  B  B  mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);

Reply via email to