With the --group-directories-first option, ls shows directories on top of all non directory entries, but IMHO symlinks to directories should be handle as directories as well.
Regards. Bert 2008-02-12 Bert Wesarg <[EMAIL PROTECTED]> ls --group-directories-first: symlinks to dirs are dirs too. src/ls.c (is_symlink_to_directory): New function. (DIRFIRST_CHECK): Use it. --- src/ls.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --quilt old/src/ls.c new/src/ls.c --- old/src/ls.c +++ new/src/ls.c @@ -2849,10 +2849,21 @@ static bool is_directory (const struct fileinfo *f) { return f->filetype == directory || f->filetype == arg_directory; } +/* Return true if F is a symlink that refers to a directory. */ +static bool +is_symlink_to_directory (const struct fileinfo *f) +{ + return (f->filetype == symbolic_link + && f->linkname + && f->linkok + && f->stat_ok + && S_ISDIR (f->linkmode)); +} + /* Put the name of the file that FILENAME is a symbolic link to into the LINKNAME field of `f'. COMMAND_LINE_ARG indicates whether FILENAME is a command-line argument. */ static void @@ -2992,12 +3003,14 @@ typedef int (*qsortFunc)(V a, V b); The do { ... } while(0) makes it possible to use the macro more like a statement, without violating C89 rules: */ #define DIRFIRST_CHECK(a, b) \ do \ { \ - bool a_is_dir = is_directory ((struct fileinfo const *) a); \ - bool b_is_dir = is_directory ((struct fileinfo const *) b); \ + bool a_is_dir = is_directory ((struct fileinfo const *) a) \ + || is_symlink_to_directory ((struct fileinfo const *) a); \ + bool b_is_dir = is_directory ((struct fileinfo const *) b) \ + || is_symlink_to_directory ((struct fileinfo const *) b); \ if (a_is_dir && !b_is_dir) \ return -1; /* a goes before b */ \ if (!a_is_dir && b_is_dir) \ return 1; /* b goes before a */ \ } \ _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils