Skip to content

Commit

Permalink
Merge pull request #156 from thbeu/fix-diff-command-once-again
Browse files Browse the repository at this point in the history
Fix diff command to only set --strip-trailing-cr if available
  • Loading branch information
rouault authored Aug 14, 2024
2 parents b538a4f + 9aed413 commit 8e23c95
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
14 changes: 13 additions & 1 deletion tests/test1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ echo -------------------------------------------------------------------------
} > s1.out


if result=$(diff --strip-trailing-cr "$EXPECT" "s1.out"); then
supports_strip_trailing_cr() {
diff --help 2>/dev/null | grep -q -- '--strip-trailing-cr'
}

run_diff() {
if supports_strip_trailing_cr; then
diff --strip-trailing-cr "$EXPECT" "s1.out"
else
diff "$EXPECT" "s1.out"
fi
}

if result=$(run_diff); then
echo "******* Stream 1 Succeeded *********"
exit 0
else
Expand Down
15 changes: 14 additions & 1 deletion tests/test2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13; do
"${SHPDUMP:-./shpdump}" test${i}.shp
done > "s2.out"

if result=$(diff --strip-trailing-cr "$EXPECT" "s2.out"); then

supports_strip_trailing_cr() {
diff --help 2>/dev/null | grep -q -- '--strip-trailing-cr'
}

run_diff() {
if supports_strip_trailing_cr; then
diff --strip-trailing-cr "$EXPECT" "s2.out"
else
diff "$EXPECT" "s2.out"
fi
}

if result=$(run_diff); then
echo "******* Stream 2 Succeeded *********"
exit 0
else
Expand Down
15 changes: 14 additions & 1 deletion tests/test3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ readonly EXPECT="${1:-$SCRIPTDIR/expect3.out}"
"${DBFDUMP:-./dbfdump}" test.dbf
} > s3.out

if result=$(diff --strip-trailing-cr "$EXPECT" "s3.out"); then

supports_strip_trailing_cr() {
diff --help 2>/dev/null | grep -q -- '--strip-trailing-cr'
}

run_diff() {
if supports_strip_trailing_cr; then
diff --strip-trailing-cr "$EXPECT" "s3.out"
else
diff "$EXPECT" "s3.out"
fi
}

if result=$(run_diff); then
echo "******* Stream 3 Succeeded *********"
exit 0
else
Expand Down

0 comments on commit 8e23c95

Please sign in to comment.