bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"ls -l" no longer outputs a useless space between mode and link count


From: Paul Eggert
Subject: "ls -l" no longer outputs a useless space between mode and link count
Date: Fri, 10 Jun 2005 12:34:08 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

After asking the Austin Group about this, it appears that there's a bug
in POSIX: it shouldn't require an extra space after the first column
in ls -l output.  I installed the following to change GNU ls to omit
the extra space if possible; this saves an output column.

2005-06-10  Paul Eggert  <address@hidden>

        Act on the Austin Group's response yesterday to XCU ERN 63; see
        <http://www.opengroup.org/austin/docs/austin_260.txt>.
        * NEWS: ls no longer outputs an extra space between mode and link count.
        * doc/coreutils.texi: Remove the extra spaces in "ls -l" output.
        * src/ls.c (any_has_acl): New var.
        (clear_files): Clear it.
        (gobble_file): Set it if a file has an ACL.
        (print_long_format): Omit needless space unless some file has an ACL.

Index: NEWS
===================================================================
RCS file: /fetish/cu/NEWS,v
retrieving revision 1.292
diff -p -u -r1.292 NEWS
--- NEWS        28 May 2005 04:22:43 -0000      1.292
+++ NEWS        10 Jun 2005 19:29:50 -0000
@@ -146,6 +146,9 @@ GNU coreutils NEWS                      
   join now supports a NUL field separator, e.g., "join -t '\0'".
   join now detects and reports incompatible options, e.g., "join -t x -t y",
 
+  ls no longer outputs an extra space between the mode and the link count
+  when none of the listed files has an ACL.
+
   If stdin is a terminal, nohup now closes it and then reopens it with an
   unreadable file descriptor.  (This step is skipped if POSIXLY_CORRECT is 
set.)
   This prevents the command from tying up an OpenSSH session after you logout.
Index: doc/coreutils.texi
===================================================================
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.261
diff -p -u -r1.261 coreutils.texi
--- doc/coreutils.texi  9 Jun 2005 09:22:27 -0000       1.261
+++ doc/coreutils.texi  10 Jun 2005 19:29:53 -0000
@@ -5500,23 +5500,23 @@ $ touch a/sub/deeper/file
 $ ls -gloRF --dired a
   a:
   total 8
-  -rw-r--r--  1    0 Dec  3 00:50 f1
-  -rw-r--r--  1    0 Dec  3 00:50 f2
-  drwxr-xr-x  3 4096 Dec  3 00:50 sub/
-  drwxr-xr-x  2 4096 Dec  3 00:50 sub2/
+  -rw-r--r-- 1    0 Jun 10 12:27 f1
+  -rw-r--r-- 1    0 Jun 10 12:27 f2
+  drwxr-xr-x 3 4096 Jun 10 12:27 sub/
+  drwxr-xr-x 2 4096 Jun 10 12:27 sub2/
 
   a/sub:
   total 4
-  drwxr-xr-x  2 4096 Dec  3 00:50 deeper/
+  drwxr-xr-x 2 4096 Jun 10 12:27 deeper/
 
   a/sub/deeper:
   total 0
-  -rw-r--r--  1 0 Dec  3 00:50 file
+  -rw-r--r-- 1 0 Jun 10 12:27 file
 
   a/sub2:
   total 0
-//DIRED// 49 51 86 88 123 126 162 166 222 228 288 292
-//SUBDIRED// 2 3 171 176 233 245 296 302
+//DIRED// 48 50 84 86 120 123 158 162 217 223 282 286
+//SUBDIRED// 2 3 167 172 228 240 290 296
 //DIRED-OPTIONS// --quoting-style=literal
 @end example
 
@@ -5545,8 +5545,8 @@ on a file whose name contains special ch
 @example
 $ touch 'a b'
 $ ls -blog --dired 'a b'
-  -rw-r--r--  1 0 Dec  3 00:52 a\ b
-//DIRED// 31 35
+  -rw-r--r-- 1 0 Jun 10 12:28 a\ b
+//DIRED// 30 34
 //DIRED-OPTIONS// --quoting-style=escape
 @end example
 
@@ -12337,7 +12337,7 @@ Then you'll see output like this:
 @example
 /:
 total 1023
--rwxr-xr-x  1 0 0 1041745 Aug 16 11:17 ls
+-rwxr-xr-x 1 0 0 1041745 Aug 16 11:17 ls
 @end example
 
 If you want to use a dynamically linked executable, say @command{bash},
Index: src/ls.c
===================================================================
RCS file: /fetish/cu/src/ls.c,v
retrieving revision 1.388
diff -p -u -r1.388 ls.c
--- src/ls.c    2 Jun 2005 05:14:32 -0000       1.388
+++ src/ls.c    10 Jun 2005 19:29:54 -0000
@@ -336,6 +336,15 @@ static struct pending *pending_dirs;
 static time_t current_time = TYPE_MINIMUM (time_t);
 static int current_time_ns = -1;
 
+/* Whether any of the files has an ACL.  This affects the width of the
+   mode column.  */
+
+#if HAVE_ACL
+static bool any_has_acl;
+#else
+enum { any_has_acl = false };
+#endif
+
 /* The number of columns to use for columns containing inode numbers,
    block sizes, link counts, owners, groups, authors, major device
    numbers, minor device numbers, and file sizes, respectively.  */
@@ -2450,6 +2459,9 @@ clear_files (void)
     }
 
   files_index = 0;
+#if HAVE_ACL
+  any_has_acl = false;
+#endif
   inode_number_width = 0;
   block_size_width = 0;
   nlink_width = 0;
@@ -2563,6 +2575,7 @@ gobble_file (char const *name, enum file
        {
          int n = file_has_acl (absolute_name, &f->stat);
          f->have_acl = (0 < n);
+         any_has_acl |= f->have_acl;
          if (n < 0)
            error (0, errno, "%s", quotearg_colon (absolute_name));
        }
@@ -3219,7 +3232,7 @@ print_long_format (const struct fileinfo
   mode_string (ST_DM_MODE (f->stat), modebuf);
 
   modebuf[10] = (FILE_HAS_ACL (f) ? '+' : ' ');
-  modebuf[11] = '\0';
+  modebuf[10 + any_has_acl] = '\0';
 
   switch (time_type)
     {
@@ -3268,7 +3281,7 @@ print_long_format (const struct fileinfo
     sprintf (p, "%s %*s ", modebuf, nlink_width,
             umaxtostr (f->stat.st_nlink, hbuf));
   }
-  p += sizeof modebuf + nlink_width + 1;
+  p += sizeof modebuf - 2 + any_has_acl + 1 + nlink_width + 1;
 
   DIRED_INDENT ();
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]