Blob Blame History Raw
#!/bin/sh
# exercise the no-newline-at-EOF bug
# Before the April 2010 fix, the "\ No newline at end of file"
# line would not be printed.

. "${srcdir=.}/init.sh"; path_prepend_ ../src

printf '\n1'      > a || framework_failure_
printf '\n0\n\n1' > b || framework_failure_
cat <<EOF > exp || framework_failure_
@@ -1,2 +1,4 @@

+0
+
 1
\ No newline at end of file
EOF

cat <<EOF > exp2 || framework_failure_
@@ -1,2 +1,4 @@

-1
+0
+
+1
\ No newline at end of file
EOF

fail=0

# So we don't have to record trailing blanks in expected output above.
opt=--suppress-blank-empty

returns_ 1 diff $opt -U1 a b > out 2> err || fail=1

sed -n '/^@@/,$p' out > k && mv k out || fail=1
compare exp out || fail=1
# expect empty stderr
compare /dev/null err || fail=1

# Repeat, but with a newline at the end of "a".
echo >> a

returns_ 1 diff $opt -U1 a b > out 2> err || fail=1

sed -n '/^@@/,$p' out > k && mv k out || fail=1
compare exp2 out || fail=1
# expect empty stderr
compare /dev/null err || fail=1

# Test for Bug#18402.
printf a > a
printf b > b
returns_ 1 diff -B a b > out 2>err || fail=1

Exit $fail