tests: stat: cover %N escaping of control characters

The default shell-escape quoting style escapes control characters in
file names (e.g. newlines) as $'...' sequences, but no test exercised
this; only the single-quote character was covered.
referenced here: https://github.com/uutils/coreutils/issues/9925

* tests/stat/stat-fmt.sh: Add a case with a file name containing
contiguous and separated newlines.
https://github.com/coreutils/coreutils/pull/271
This commit is contained in:
Sylvestre Ledru authored and Pádraig Brady committed 2026-05-29 19:19:36 +01:00
1 parent 255febf98b
commit cec863ff08
1 file changed
+13
+13
View File
@@ -40,6 +40,19 @@ cat <<\EOF >exp
EOF
compare exp out || fail=1
# ensure control characters in file names are escaped by %N
# using the default shell-escape quoting style.
nl='
'
fname="a${nl}${nl}b${nl}c"
touch "$fname" || framework_failure_
stat -c%N "$fname" > out || fail=1
# contiguous control characters are clumped into one $'...' escape.
cat <<\EOF >exp
'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