patchGNU Core Utilities - Patches: patch #3596, Sort directories before files in...

 
 

You are not allowed to post comments on this tracker with your current authentification level.

patch #3596: Sort directories before files in "ls"

Submitted by:  None
Submitted on:  Sun 26 Dec 2004 09:03:49 PM UTC  
Votes:  105  
 
Category: NonePriority: 5 - Normal
Status: Ready For TestPrivacy: Public
Assigned to: NoneOriginator Email: -unavailable-
Open/Closed: Open

(Jump to the original submission Jump to the original submission)

Thu 14 Dec 2006 11:28:32 AM UTC, comment #6:

This is an enhancement for the actual implementation for the '--group-directories-first' option in ls, so that symbolic links to directories are handled as directories with this option enabled.

(file #11524)

Bert Wesarg <lebert>
Sun 30 Apr 2006 02:47:17 AM UTC, comment #5:

A derivative of the ideas in this patch tracker has been committed to CVS this week, so in coreutils 6.0, you will be able to do 'ls --group-directories-first'. Burning another short option letter (such as the suggested -e) was deemed inappropriate for ls, which already has more than its fair share of short options.

Eric Blake <ericb>
Project Administrator
Sat 10 Dec 2005 10:19:42 AM UTC, comment #4:

PS: a couple of things I forgot:
1) I added another small patch which modifies also the coreutils.texi file
2) I assign the copyright to the FSF for all my patches submitted in this tracker

Francesco Montorsi <frm>
Fri 09 Dec 2005 08:19:17 PM UTC, comment #3:

I've added to this tracker a new patch which should address all issues raised by Eric Blake.

The only thing left out are systems without dirent.d_type: a stat for each file isn't going to be too slow ?
Maybe that for those systems without dirent.d_type, it's better to just not implement this option....

Please let me know if something needs to be changed.
Francesco

NOTE1: symlinks to directories are treated as simple files.

NOTE2: I couldn't think of any long option which begins with an unused char; so I have used the -e option together with the long option --group-directories

Francesco Montorsi <frm>
Fri 09 Dec 2005 11:38:17 AM UTC, comment #2:

If the original patch author doesn't mind, I'll try to make the changes suggested by Eric Blake and then make a new patch.
I'll let you know.

Francesco Montorsi <frm>
Mon 05 Dec 2005 02:04:18 PM UTC, comment #1:

Several problems with the proposed patch:

No ChangeLog. Also, your patch is incomplete without also touching NEWS and doc/coreutils.texi, not to mention updating the testsuite.

It is big enough that you would need to assign copyright to the FSF before we can consider it.

You did not add a corresponding long option for -e; and -e does not really have a good mneumonic to imply what it is doing (although -d and -D are already taken for --directories-first, and -g and -G are already taken for --group-directories-first. It would be nice if the long option could start with the same letter as the proposed short option).

Your proposed patch treats directory sorts as equal with all other sorts, meaning that there is no way to group directories first, but then sort directories by size and files by size. I envision this feature as independent from --sort, that when it is enabled, directories are always sorted first, but that then the two groups (dirs and non-dirs) can be additionally sorted by whatever --sort option is in effect. That also means that in a --reverse sort, I think directories should still be listed first, not last.

Your patch does not take into account the fact that on systems without dirent.d_type, you will need to stat every file to ensure which files are directories before you can meaningfully group directories first.

Your patch does not take into account what behavior should be used with symlinks to dirs - are they grouped with directories, or with files, or does it depend on other options (such as -L)?

Eric Blake <ericb>
Project Administrator
Sun 26 Dec 2004 09:03:49 PM UTC, original submission:

Added new option "-e" to ls to sort directories before sorting files. e.g:

<pre>
[22:02][lurch]$ /bin/ls -l
total 8
drwxr-xr-x 2 lurch users 4096 Dec 26 22:02 a
-rw-r--r-- 1 lurch users 0 Dec 26 22:02 b
drwxr-xr-x 2 lurch users 4096 Dec 26 22:02 c
-rw-r--r-- 1 lurch users 0 Dec 26 22:02 e
[22:02][lurch]$ /bin/ls -le
total 8
drwxr-xr-x 2 lurch users 4096 Dec 26 22:02 a
drwxr-xr-x 2 lurch users 4096 Dec 26 22:02 c
-rw-r--r-- 1 lurch users 0 Dec 26 22:02 b
-rw-r--r-- 1 lurch users 0 Dec 26 22:02 e
</pre>

Anonymous

 

Attached Files
file #11524:  ls_--group-directories-first_symlinks_to_dir_are_dirs_too.patch added by lebert (1kB - text/x-patch - handle symlinks to dirs as dirs in option --group-directories-first)
file #9058:  changelog.patch added by frm (960B - text/x-patch - Changelog patch)
file #4136:  doc.patch added by frm (687B - text/x-patch - This one really needs testing as I don't know the Tex language ;))
file #4135:  ls-group-dirs.patch added by frm (5kB - text/x-patch)
file #8207:  coreutils-5.2.1-ls.patch added by None (2kB - application/octet-stream - Add "-e" option to ls to sort directories before files)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mikelward (Voted in favor of this item)
  • -unavailable- added by lebert (Updated the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 105 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 17 Aug 2011 07:29:15 PM UTCmikelwardCarbon-Copy-=>Added mikelward
    Thu 14 Dec 2006 11:28:32 AM UTClebertAttached File-=>Added ls_--group-directories-first_symlinks_to_dir_are_dirs_too.patch, #11524
    Sun 30 Apr 2006 02:47:17 AM UTCericbStatusNone=>Ready For Test
    Tue 27 Dec 2005 06:41:49 PM UTCfrmAttached File-=>Added changelog.patch, #5665
    Sat 10 Dec 2005 10:19:42 AM UTCfrmAttached File-=>Added doc.patch, #5571
    Fri 09 Dec 2005 08:19:17 PM UTCfrmAttached File-=>Added ls-group-dirs.patch, #5570
    Fri 09 Dec 2005 11:38:17 AM UTCfrmCarbon-Copy-=>Added -unavailable-
    Fri 09 Dec 2005 11:36:22 AM UTCfrmCarbon-Copy-=>Added frm
    Sun 26 Dec 2004 09:03:49 PM UTCNoneAttached File-=>Added coreutils-5.2.1-ls.patch, #3974

    Back to the top


    Powered by Savane 3.1-cleanup