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)
{
out_string (pformat, prefix_len, filename);
break;
case 'N':
+ getenv_quoting_style ();
out_string (pformat, prefix_len, quoteN (filename));
if (S_ISLNK (statbuf->st_mode))
{
if (format)
{
- bool need_quoting_style = false;
- for (char const *p = format; (p = strchr (p, '%'));
- p += (p[1] == '%') + 1)
- {
- if (p[1] == 'N')
- {
- need_quoting_style = true;
- break;
- }
- }
- if (need_quoting_style)
- getenv_quoting_style ();
format2 = format;
}
else
EOF
compare exp out || fail=1
+# ensure control characters in file names are escaped by default
+stat "$fname" | grep 'File: ' > out || fail=1
+cat <<\EOF >exp
+ File: 'a'$'\n\n''b'$'\n''c'
+EOF
+compare exp out || fail=1
+
# Check the behavior with invalid values of QUOTING_STYLE.
for style in '' 'abcdef'; do
QUOTING_STYLE="$style" stat -c%%%N \' > out 2> err || fail=1