Package: coreutils Version: 8.13-3.1 Severity: normal Tags: patch While in the source of ls, I noticed an easy way to get it to do something I've always wanted; display the contents of multiple directories as if they were all in a single directory. Since -u (for "union") is already in use, I picked option -e for entangle.
For example: joey@gnu:/tmp> ls foo bar -e barfile foofile It also works with -l (and other output formats), although for -l, I left it displaying the individual directory block sizes. Summing them would be a nice improvement. joey@gnu:/tmp> ls foo bar . -e -l total 0 total 0 total 0 drwxr-xr-x 2 joey joey 60 Mar 29 18:18 bar -rw-r--r-- 1 joey joey 0 Mar 29 18:18 barfile drwxr-xr-x 2 joey joey 60 Mar 29 18:17 foo -rw-r--r-- 1 joey joey 0 Mar 29 18:17 foofile drwx------ 2 joey joey 60 Mar 29 11:07 gpg-AXD46h drwx------ 2 joey joey 60 Mar 29 11:07 ssh-BDuydssP2259 -- System Information: Debian Release: wheezy/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Kernel: Linux 3.1.0-1-686-pae (SMP w/2 CPU cores) Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages coreutils depends on: ii dpkg 1.16.2 ii install-info 4.13a.dfsg.1-8 ii libacl1 2.2.51-5 ii libattr1 1:2.4.46-5 ii libc6 2.13-27 ii libselinux1 2.1.9-2 coreutils recommends no packages. coreutils suggests no packages. -- no debconf information -- see shy jo
--- orig/coreutils-8.13/src/ls.c 2012-03-29 18:14:41.259588986 -0400 +++ coreutils-8.13/src/ls.c 2012-03-29 18:12:25.867495042 -0400 @@ -633,6 +633,11 @@ static bool immediate_dirs; +/* True means when multiple directories are being displayed, combine + * their contents as if all in one directory. -e */ + +static bool entangle_dirs; + /* True means that directories are grouped before files. */ static bool directories_first; @@ -811,6 +816,7 @@ {"escape", no_argument, NULL, 'b'}, {"directory", no_argument, NULL, 'd'}, {"dired", no_argument, NULL, 'D'}, + {"entangle", no_argument, NULL, 'e'}, {"full-time", no_argument, NULL, FULL_TIME_OPTION}, {"group-directories-first", no_argument, NULL, GROUP_DIRECTORIES_FIRST_OPTION}, @@ -1455,6 +1461,9 @@ print_dir_name = true; } + if (entangle_dirs) + print_current_files (); + if (print_with_color) { int j; @@ -1652,7 +1661,7 @@ { int oi = -1; int c = getopt_long (argc, argv, - "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1", + "abcdefghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1", long_options, &oi); if (c == -1) break; @@ -1675,6 +1684,10 @@ immediate_dirs = true; break; + case 'e': + entangle_dirs = true; + break; + case 'f': /* Same as enabling -a -U and disabling -l -s. */ ignore_mode = IGNORE_MINIMAL; @@ -2526,7 +2539,7 @@ DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino); } - if (recursive || print_dir_name) + if ((recursive || print_dir_name) && ! entangle_dirs) { if (!first) DIRED_PUTCHAR ('\n'); @@ -2542,7 +2555,8 @@ /* Read the directory entries, and insert the subfiles into the `cwd_file' table. */ - clear_files (); + if (! entangle_dirs) + clear_files (); while (1) { @@ -2631,7 +2645,7 @@ DIRED_PUTCHAR ('\n'); } - if (cwd_n_used) + if (cwd_n_used && ! entangle_dirs) print_current_files (); } @@ -4665,6 +4679,7 @@ -D, --dired generate output designed for Emacs' dired mode\n\ "), stdout); fputs (_("\ + -e, --entangle display multiple directory contents as one\n\ -f do not sort, enable -aU, disable -ls --color\n\ -F, --classify append indicator (one of */=>@|) to entries\n\ --file-type likewise, except do not append `*'\n\
signature.asc
Description: Digital signature