Subject: bug#28763: docbug (stat -t): missing field names in docs(manpage) for 'stat -t'

From: Assaf Gordon <[email-masked]>
Date: Thu, 12 Oct 2017 00:51:14 -0600

On 2017-10-12 12:01 AM, Bernhard Voelker wrote:
> On 10/12/2017 05:27 AM, Pádraig Brady wrote:
>> I'd be a bit happier if it was more terse (pardon the pun).
> 
> +1

Thank you all for the suggestions and improvements.

Attached an updated patch.

regards,
 - assaf

>From 00c5dd601c8227e1384de314e8a5dc420a56b272 Mon Sep 17 00:00:00 2001
From: Assaf Gordon <[email-masked]>
Date: Wed, 11 Oct 2017 22:33:28 +0200
Subject: [PATCH] stat: output default formats for --terse in usage

Suggested by L A Walsh in https://bugs.gnu.org/28763 .

* src/stat.c (fmt_terse_fs): Define format for --terse -f here.
(fmt_terse_regular): Define format for --terse here.
(fmt_terse_selinux): Likewise for when SELinux is enabled.
(default_format): Use the above constants.
(usage): Output the formats for the terse modes.
---
 src/stat.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/stat.c b/src/stat.c
index e505de7..a6313e6 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -178,6 +178,13 @@ static char const digits[] = "0123456789";
    out_epoch_sec.  */
 static char const printf_flags[] = "'-+ #0I";
 
+/* Formats for the --terse option.  */
+static char const fmt_terse_fs[] = "%n %i %l %t %s %S %b %f %a %c %d\n";
+static char const fmt_terse_regular[] = "%n %s %b %f %u %g %D %i %h %t %T"
+                                        " %X %Y %Z %W %o\n";
+static char const fmt_terse_selinux[] = "%n %s %b %f %u %g %D %i %h %t %T"
+                                        " %X %Y %Z %W %o %C\n";
+
 #define PROGRAM_NAME "stat"
 
 #define AUTHORS proper_name ("Michael Meskes")
@@ -1399,7 +1406,7 @@ default_format (bool fs, bool terse, bool device)
   if (fs)
     {
       if (terse)
-        format = xstrdup ("%n %i %l %t %s %S %b %f %a %c %d\n");
+        format = xstrdup (fmt_terse_fs);
       else
         {
           /* TRANSLATORS: This string uses format specifiers from
@@ -1416,11 +1423,9 @@ default_format (bool fs, bool terse, bool device)
       if (terse)
         {
           if (0 < is_selinux_enabled ())
-            format = xstrdup ("%n %s %b %f %u %g %D %i %h %t %T"
-                              " %X %Y %Z %W %o %C\n");
+            format = xstrdup (fmt_terse_selinux);
           else
-            format = xstrdup ("%n %s %b %f %u %g %D %i %h %t %T"
-                              " %X %Y %Z %W %o\n");
+            format = xstrdup (fmt_terse_regular);
         }
       else
         {
@@ -1571,6 +1576,23 @@ Valid format sequences for file systems:\n\
   %t   file system type in hex\n\
   %T   file system type in human readable form\n\
 "), stdout);
+
+      printf (_("\n\
+--terse is equivalent to the following FORMAT:\n\
+    %s\
+"),
+#if HAVE_SELINUX_SELINUX_H
+              fmt_terse_selinux
+#else
+              fmt_terse_regular
+#endif
+              );
+
+        printf (_("\
+--terse --file-system is equivalent to the following FORMAT:\n\
+    %s\
+"), fmt_terse_fs);
+
       printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
       emit_ancillary_info (PROGRAM_NAME);
     }
-- 
2.7.4