I came across a quirk with 'du' when the order of some args are different.

Suppose there is a file named "foo.txt".
The following commands give different results:
   du --bytes --human-readable foo.txt
   du --human-readable --bytes foo.txt

Actual results:
The values displayed are different (one is the amount of bytes and the other
is the amount of bytes printed in a human readable format).

Expected results:
The values displayed are the same (should be the amount of bytes printed in
a human readable format)

Is it incorrect to expect that the two commands with the args in a different
order would give different results?

Here are the steps to reproduce...

####################

[EMAIL PROTECTED] ~]$ uname -a
Linux localhost.localdomain 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:35:01 EDT
2007 i686 athlon i386 GNU/Linux

[EMAIL PROTECTED] ~]$ du --version
du (GNU coreutils) 6.9
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim
Meyering.

[EMAIL PROTECTED] ~]$ du --bytes foo.txt
2215936 foo.txt

[EMAIL PROTECTED] ~]$ du --human-readable foo.txt
2.2M foo.txt

[EMAIL PROTECTED] ~]$ du --bytes --human-readable foo.txt
2.2M foo.txt

[EMAIL PROTECTED] ~]$ du --human-readable --bytes foo.txt
2215936 foo.txt

####################

Looking at the source code in du.c:

//-------------------

case 'b':
 apparent_size = true;
 human_output_opts = 0;
 output_block_size = 1;
 break;

/* <snip> */

case 'h':
 human_output_opts = human_autoscale | human_SI | human_base_1024;
 output_block_size = 1;
 break;

//-------------------

Why does "--bytes" turn off "--human-readable"?
Why does "--human-readable" turn on "--block-size=1"?


Steve Ward
_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to