diffutils/tests/filename-quoting
Paul Eggert 774b942f70 diff: go back to C quoting for diff -c/-u headers
Gleb Fotengauer-Malinovskiy reported <https://bugs/gnu/org/66095>
that the recent change to quoting style broke GNU patch.
* src/util.c: Include quotearg.h.
(current_name): New static var, replacing the the old
current_name0 and current_name1.  All uses changed.
(begin_output): Go back to quoting file names for C,
not for the shell, when they contain troublesome characters.
This is not a simple revert, as the revised code handles
multi-byte characters even in non-UTF-8 locales.
* tests/filename-quoting: Revert previous change to this file.
2023-09-20 00:05:00 -07:00

62 lines
1023 B
Bash
Executable File

#!/bin/sh
# filename quoting
. "${srcdir=.}/init.sh"; path_prepend_ ../src
fail=0
cat <<EOF > exp- || fail=1
diff -N -r "a/ " "b/ "
0a1
> space
EOF
cat <<EOF > exp--u || fail=1
diff -N -r -u "a/ " "b/ "
--- "a/ "
+++ "b/ "
@@ -0,0 +1 @@
+space
EOF
cat <<EOF > exp--c || fail=1
diff -N -r -c "a/ " "b/ "
*** "a/ "
--- "b/ "
***************
*** 0 ****
--- 1 ----
+ space
EOF
mkdir a b
echo space > "b/ " || fail=1
for opt in '' -u -c; do
returns_ 1 diff -N -r $opt a b > out 2> err || fail=1
# Remove date and time.
sed -e 's/^\([-+*][-+*][-+*] [^ ]*\) .*/\1/' out > k; mv k out
compare exp-$(echo $opt|tr ' ' _) out || fail=1
done
rm -f "b/ "
cat <<EOF > exp || fail=1
--- "a/\t"
+++ "b/\001"
@@ -1 +1 @@
-tab
+one
EOF
tab=$(printf '\t')
x01=$(printf '\001')
echo tab > "a/$tab" || fail=1
echo one > "b/$x01" || fail=1
returns_ 1 diff -u "a/$tab" "b/$x01" > out 2> err || fail=1
# Remove date and time.
sed -e 's/^\([-+*][-+*][-+*] [^ ]*\) .*/\1/' out > k; mv k out
compare exp out || fail=1
Exit $fail