@item %i -- Inode number
@item %m -- Mount point (see selow)
@item %n -- File name
+@item %Qn -- Quoted file name (see below)
@item %N -- Quoted file name with dereference if symbolic link (see below)
@item %o -- Optimal I/O transfer size hint
@item %s -- Total size, in bytes
printf flags. For example to pad to at least 3 wide while making larger
numbers unambiguously octal, you can use @samp{%#03a}.
-The @samp{%N} format can be set with the environment variable
+The @samp{%N} and @samp{%Qn} formats can be set with the environment variable
@env{QUOTING_STYLE}@. If that environment variable is not set,
the default value is @samp{shell-escape-always}. Valid quoting styles are:
@quotingStyles
@item %i -- File System ID in hex
@item %l -- Maximum length of file names
@item %n -- File name
+@item %Qn -- Quoted file name
@item %s -- Block size (for faster transfers)
@item %S -- Fundamental block size (for block counts)
@item %t -- Type in hex
return fail;
}
+/* Set the quoting style default if the environment variable
+ QUOTING_STYLE is set. */
+
+static void
+getenv_quoting_style (void)
+{
+ static bool got_quoting_style;
+ if (got_quoting_style)
+ return;
+ got_quoting_style = true;
+
+ char const *q_style = getenv ("QUOTING_STYLE");
+ if (q_style)
+ {
+ int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals);
+ if (0 <= i)
+ set_quoting_style (NULL, quoting_style_vals[i]);
+ else
+ {
+ set_quoting_style (NULL, shell_escape_always_quoting_style);
+ error (0, 0, _("ignoring invalid value of environment "
+ "variable QUOTING_STYLE: %s"), quote (q_style));
+ }
+ }
+ else
+ set_quoting_style (NULL, shell_escape_always_quoting_style);
+}
+
+/* Equivalent to quotearg(), but explicit to avoid syntax checks. */
+#define quoteN(x) quotearg_style (get_quoting_style (NULL), x)
+
/* Print statfs info. Return zero upon success, nonzero upon failure. */
NODISCARD
static bool
switch (m)
{
case 'n':
+ if (mod == 'Q')
+ {
+ getenv_quoting_style ();
+ filename = quoteN (filename);
+ }
out_string (pformat, prefix_len, filename);
break;
return z;
}
-/* Set the quoting style default if the environment variable
- QUOTING_STYLE is set. */
-
-static void
-getenv_quoting_style (void)
-{
- static bool got_quoting_style;
- if (got_quoting_style)
- return;
- got_quoting_style = true;
-
- char const *q_style = getenv ("QUOTING_STYLE");
- if (q_style)
- {
- int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals);
- if (0 <= i)
- set_quoting_style (NULL, quoting_style_vals[i]);
- else
- {
- set_quoting_style (NULL, shell_escape_always_quoting_style);
- error (0, 0, _("ignoring invalid value of environment "
- "variable QUOTING_STYLE: %s"), quote (q_style));
- }
- }
- else
- set_quoting_style (NULL, shell_escape_always_quoting_style);
-}
-
-/* Equivalent to quotearg(), but explicit to avoid syntax checks. */
-#define quoteN(x) quotearg_style (get_quoting_style (NULL), x)
-
/* Output a single-character \ escape. */
static void
break;
case 'H':
case 'L':
+ case 'Q':
mod_char = fmt_char;
fmt_char = *(b + 1);
- if (print_func == print_stat
- && (fmt_char == 'd' || fmt_char == 'r'))
+ if ((mod_char == 'Q' && fmt_char == 'n')
+ || (print_func == print_stat
+ && (mod_char == 'H' || mod_char == 'L')
+ && (fmt_char == 'd' || fmt_char == 'r')))
{
b++;
}
switch (m)
{
case 'n':
+ if (mod == 'Q')
+ {
+ getenv_quoting_style ();
+ filename = quoteN (filename);
+ }
out_string (pformat, prefix_len, filename);
break;
case 'N':
%i inode number\n\
%m mount point\n\
%n file name\n\
+ %Qn quoted file name\n\
%N quoted file name with dereference if symbolic link\n\
%o optimal I/O transfer size hint\n\
%s total size, in bytes\n\
%i file system ID in hex\n\
%l maximum length of filenames\n\
%n file name\n\
+ %Qn quoted file name\n\
%s block size (for faster transfers)\n\
%S fundamental block size (for block counts)\n\
%t file system type in hex\n\