Subject: Re: bug#17546: Problem with du

From: Paul Eggert <[email-masked]>
Date: Wed, 21 May 2014 19:42:11 -0700

Dale R. Worley wrote:
> before release 8.6, the order of arguments didn't matter

No, order mattered even back then.  For example:

$ du --version | sed 1q
du (GNU coreutils) 8.4
$ ls -li d/* e/*
11765482 -rw-r--r-- 1 eggert csfac 159910666 May  1 20:42 d/j
23558745 -rw-r--r-- 2 eggert csfac 410000000 Apr 22 21:34 d/k
23558745 -rw-r--r-- 2 eggert csfac 410000000 Apr 22 21:34 e/k
$ du d e d e
557664	d
4	e
156480	d
4	e
$ du e d e d
401188	e
156480	d
4	e
156480	d

So file argument order affected link counts even back then; it's just 
that before 8.6 this was true only for files with link count greater 
than 1, which led to odd behaviors such as the behavior shown above. 
What changed in 8.6 is that the behavior was made consistent for all 
files, not just those with link count greater than 1. so that for the 
same data the current version of du generates output like this:

$ du --version | sed 1q
du (GNU coreutils) 8.22
$ du d e d e
557664	d
4	e
$ du e d e d
401188	e
156480	d

This sums to the same values independent of file order, which is a plus.

As far as I can see, POSIX doesn't allow the old behavior, but does 
allow the new one.

> This leads to startlingly odd behaviors

Any choice of behavior for 'du' will lead to odd behaviors sometimes, 
and there's no way we can make everybody happy in all cases.  There is 
an important technical advantage of du's current behavior, though; you 
can get the behavior you prefer by running "du X; du Y".  If we chaned 
du to reset itself between command-line arguments, there'd be no way to 
get the behavior I prefer, which is to count files just once.