From f512a23bb76e613e776ee29a39ccd79f20b96fcb Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Tue, 13 Aug 2024 16:25:59 +0200 Subject: [PATCH 1/2] Fix diff command to only set --strip-trailing-cr on Win --- contrib/tests/shpproj.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/contrib/tests/shpproj.sh b/contrib/tests/shpproj.sh index f6aecd9..229b269 100755 --- a/contrib/tests/shpproj.sh +++ b/contrib/tests/shpproj.sh @@ -21,8 +21,19 @@ readonly SCRIPTDIR=$(dirname "$0") "${SHPDUMP:-$top_builddir/shpdump}" -precision 8 "test" > "test.out" - -if result=$(diff --strip-trailing-cr "$SCRIPTDIR/expect.out" "test.out"); then +is_windows() { + [ -n "$WINDIR" ] || uname | grep -q "MINGW" +} + +run_diff() { + if is_windows; then + diff --strip-trailing-cr "$SCRIPTDIR/expect.out" "test.out" + else + diff "$SCRIPTDIR/expect.out" "test.out" + fi +} + +if result=$(run_diff); then echo "******* Test Succeeded *********" exit 0 else From d3d8de3a5ab5f002dca86c624f7d8b132cf1eb9a Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Tue, 13 Aug 2024 18:53:17 +0200 Subject: [PATCH 2/2] Check if diff supports the --strip-trailing-cr option --- contrib/tests/shpproj.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/tests/shpproj.sh b/contrib/tests/shpproj.sh index 229b269..9eefa0d 100755 --- a/contrib/tests/shpproj.sh +++ b/contrib/tests/shpproj.sh @@ -21,12 +21,12 @@ readonly SCRIPTDIR=$(dirname "$0") "${SHPDUMP:-$top_builddir/shpdump}" -precision 8 "test" > "test.out" -is_windows() { - [ -n "$WINDIR" ] || uname | grep -q "MINGW" +supports_strip_trailing_cr() { + diff --help 2>/dev/null | grep -q -- '--strip-trailing-cr' } run_diff() { - if is_windows; then + if supports_strip_trailing_cr; then diff --strip-trailing-cr "$SCRIPTDIR/expect.out" "test.out" else diff "$SCRIPTDIR/expect.out" "test.out"