>From 15a21fe54690a8ed4422cb5ff1b27f7f2836b3df Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Wed, 11 Oct 2017 22:33:28 +0200 Subject: [PATCH] stat: output default formats for --terse in usage * 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 | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/stat.c b/src/stat.c index e505de7..e533a00 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,18 @@ 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 without SELinux is equivalent to the following FORMAT:\n\ + %s\ +--terse with SELinux enabled is equivalent to the following FORMAT:\n\ + %s\ +"), fmt_terse_regular, fmt_terse_selinux); + 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.1.4