The format string would include another @samp{%C} at the end with an
active SELinux security context.
@example
-$ stat --format="%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o" ...
+$ stat --format="%Qn %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o" ...
$ stat --terse ...
@end example
The same illustrating terse output in @option{--file-system} mode:
@example
-$ stat -f --format="%n %i %l %t %s %S %b %f %a %c %d" ...
+$ stat -f --format="%Qn %i %l %t %s %S %b %f %a %c %d" ...
$ stat -f --terse ...
@end example
@end table
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"
+static char const fmt_terse_fs[] = "%Qn %i %l %t %s %S %b %f %a %c %d\n";
+static char const fmt_terse_regular[] = "%Qn %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"
+static char const fmt_terse_selinux[] = "%Qn %s %b %f %u %g %D %i %h %t %T"
" %X %Y %Z %W %o %C\n";
#define PROGRAM_NAME "stat"
{
/* TRANSLATORS: This string uses format specifiers from
'stat --help' with --file-system, and NOT from printf. */
- format = xstrdup (_(" File: \"%n\"\n"
+ format = xstrdup (_(" File: %Qn\n"
" ID: %-8i Namelen: %-7l Type: %T\n"
"Block size: %-10s Fundamental block size: %S\n"
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
File: 'a'$'\n\n''b'$'\n''c'
EOF
compare exp out || fail=1
+# likewise with --terse
+stat --terse "$fname" | cut -d ' ' -f1 > out || fail=1
+cat <<\EOF >exp
+'a'$'\n\n''b'$'\n''c'
+EOF
+compare exp out || fail=1
+stat -f --terse "$fname" | cut -d ' ' -f1 > out || fail=1
+compare exp out || fail=1
# Check the behavior with invalid values of QUOTING_STYLE.
for style in '' 'abcdef'; do