Skip to content

Commit 8e23c95

Browse files
authored
Merge pull request #156 from thbeu/fix-diff-command-once-again
Fix diff command to only set --strip-trailing-cr if available
2 parents b538a4f + 9aed413 commit 8e23c95

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

Diff for: tests/test1.sh

+13-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,19 @@ echo -------------------------------------------------------------------------
3434
} > s1.out
3535

3636

37-
if result=$(diff --strip-trailing-cr "$EXPECT" "s1.out"); then
37+
supports_strip_trailing_cr() {
38+
diff --help 2>/dev/null | grep -q -- '--strip-trailing-cr'
39+
}
40+
41+
run_diff() {
42+
if supports_strip_trailing_cr; then
43+
diff --strip-trailing-cr "$EXPECT" "s1.out"
44+
else
45+
diff "$EXPECT" "s1.out"
46+
fi
47+
}
48+
49+
if result=$(run_diff); then
3850
echo "******* Stream 1 Succeeded *********"
3951
exit 0
4052
else

Diff for: tests/test2.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13; do
1212
"${SHPDUMP:-./shpdump}" test${i}.shp
1313
done > "s2.out"
1414

15-
if result=$(diff --strip-trailing-cr "$EXPECT" "s2.out"); then
15+
16+
supports_strip_trailing_cr() {
17+
diff --help 2>/dev/null | grep -q -- '--strip-trailing-cr'
18+
}
19+
20+
run_diff() {
21+
if supports_strip_trailing_cr; then
22+
diff --strip-trailing-cr "$EXPECT" "s2.out"
23+
else
24+
diff "$EXPECT" "s2.out"
25+
fi
26+
}
27+
28+
if result=$(run_diff); then
1629
echo "******* Stream 2 Succeeded *********"
1730
exit 0
1831
else

Diff for: tests/test3.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,20 @@ readonly EXPECT="${1:-$SCRIPTDIR/expect3.out}"
2727
"${DBFDUMP:-./dbfdump}" test.dbf
2828
} > s3.out
2929

30-
if result=$(diff --strip-trailing-cr "$EXPECT" "s3.out"); then
30+
31+
supports_strip_trailing_cr() {
32+
diff --help 2>/dev/null | grep -q -- '--strip-trailing-cr'
33+
}
34+
35+
run_diff() {
36+
if supports_strip_trailing_cr; then
37+
diff --strip-trailing-cr "$EXPECT" "s3.out"
38+
else
39+
diff "$EXPECT" "s3.out"
40+
fi
41+
}
42+
43+
if result=$(run_diff); then
3144
echo "******* Stream 3 Succeeded *********"
3245
exit 0
3346
else

0 commit comments

Comments
 (0)