'install -C' will now avoid updating file metadata when the destination
already has the appropriate ownership and permissions.
- 'realpath' now quotes output in shell-escape style when
+ 'basename' and 'realpath' now quote output in shell-escape style when
standard output is a terminal. The QUOTING_STYLE environment variable
can be used to adjust or disable the quoting.
@end table
+When standard output is a terminal, output is quoted using the
+@samp{shell-escape} style. The environment variable
+@env{QUOTING_STYLE} specifies the quoting style. Valid quoting styles are:
+@quotingStyles
+
@exitstatus
Examples:
#include <stdio.h>
#include <sys/types.h>
+#include "argmatch.h" /* argmatch($QUOTING_STYLE). */
#include "system.h"
#include "quote.h"
#define AUTHORS proper_name ("David MacKenzie")
+static bool quote_output;
+
static struct option const longopts[] =
{
{"multiple", no_argument, NULL, 'a'},
&& ! FILE_SYSTEM_PREFIX_LEN (name))
remove_suffix (name, suffix, suffix_len);
- fputs (name, stdout);
+ fputs (quote_output ? quoteN (name) : name, stdout);
putchar (use_nuls ? '\0' : '\n');
free (name);
}
}
}
+ if (!use_nuls && isatty (STDOUT_FILENO))
+ {
+ int qs = getenv_quoting_style ();
+ if (qs < 0)
+ qs = shell_escape_quoting_style;
+ if (qs != literal_quoting_style)
+ {
+ set_quoting_style (NULL, qs);
+ quote_output = true;
+ }
+ }
+
idx_t suffix_len = suffix ? strlen (suffix) : 0;
char **file = argv + optind;
['9', qw(fs ''), {OUT => 'fs'}],
['10', qw(fs/ s/), {OUT => 'fs'}],
+ # QUOTING_STYLE does not affect redirected output.
+ ['q-lit', q{'d/q name'}, {ENV => 'QUOTING_STYLE=literal'},
+ {OUT => 'q name'}],
+ ['q-shell', q{'d/q name'}, {ENV => 'QUOTING_STYLE=shell-always'},
+ {OUT => 'q name'}],
+ ['q-invalid', q{'d/q name'}, {ENV => 'QUOTING_STYLE=invalid'},
+ {OUT => 'q name'}],
+
# Exercise -z option.
['z0', qw(-z a), {OUT => "a\0"}],
['z1', qw(--zero a), {OUT => "a\0"}],
['z2', qw(-za a b), {OUT => "a\0b\0"}],
['z3', qw(-z ba a), {OUT => "b\0"}],
['z4', qw(-z -s a ba), {OUT => "b\0"}],
+ ['z-quote', q{-z 'q name'}, {ENV => 'QUOTING_STYLE=invalid'},
+ {OUT => "q name\0"}],
);
# Append a newline to end of each expected 'OUT' string.