Justin Pryzby <[EMAIL PROTECTED]> wrote: > On Wed, Apr 18, 2007 at 05:11:38AM +0200, Jim Meyering wrote: >> Justin Pryzby <[EMAIL PROTECTED]> wrote: >> > This bug is not fixed. The code in coreutils-6.9 fails to treat -D as >> > an option independent of -P and -L. This has the effect that -D implies >> > -L, and du -DL is not the same as du -LD. >> >> Please provide an example demonstrating this. >> Or point to parts of the code and explain how that can be true. > So I think we agree on the intended behavior. > >> FYI the relevant parts sure seem orthogonal to me: > int symlink_deref_bits = FTS_PHYSICAL; > >> case 'D': /* This will eventually be 'H' (-H), too. */ >> symlink_deref_bits = FTS_COMFOLLOW | FTS_PHYSICAL; >> break; >> >> case 'L': /* --dereference */ >> symlink_deref_bits = FTS_LOGICAL; >> break; >> >> case 'P': /* --no-dereference */ >> symlink_deref_bits = FTS_PHYSICAL; >> break; > I'm afraid my example was wrong. > > If I call du -DP I get symlink_deref_bits=FTS_PHYSICAL, but if I call > du -PD I get symlink_dref_bits=FTS_COMFOLLOW|FTS_PHYSICAL.
That is deliberate. Last one used (of -D, -P, -L) takes effect. There's even a section explaining how -H, -L, -P change how symlinks are traversed. Once du changes its -H to mean -D, it too will be listed in the "Traversing Symlinks" section, below. > -L and -P are not independent (as intended); -D (eventually known as > -H) *should* be independent. (-L internally implies -D, but > applications don't have to and shouldn't deal with this). With -D, du dereferences all command-line-specified symlinks. With -L, it dereferences all (including ones encountered via a traversal). With -P, it doesn't dereference any symlink. So there is some overlap, but it is deliberate, and required. If you still have questions about du's correctness, please compare the code with the POSIX spec and/or the documentation ("info coreutils du"). You might want to look at fts.[ch] for how the FTS_* macros are used. ----------------- 2.6 Traversing symlinks ======================= The following options modify how `chown' and `chgrp' traverse a hierarchy when the `--recursive' (`-R') option is also specified. If more than one of the following options is specified, only the final one takes effect. These options specify whether processing a symbolic link to a directory entails operating on just the symbolic link or on all files in the hierarchy rooted at that directory. These options are independent of `--dereference' and `--no-dereference' (`-h'), which control whether to modify a symlink or its referent. `-H' If `--recursive' (`-R') is specified and a command line argument is a symbolic link to a directory, traverse it. `-L' In a recursive traversal, traverse every symbolic link to a directory that is encountered. `-P' Do not traverse any symbolic links. This is the default if none of `-H', `-L', or `-P' is specified. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]