# HG changeset patch # User FUJIWARA Katsunori # Date 2017-07-31 04:10:19 # Node ID a2b55ee62803ad33f2694d3891aa396198c5b678 # Parent a72b2db1a6a9f82b5576dfcbac059f10836e6b79 tests: make pdiff return appropriate exit code at comparison of files Before this patch, pdiff script returns 0, even if diff is detected. This issue doesn't cause failure of tests using it, if it is invoked via extdiff extension, because extdiff itself examines changes between specified revisions and decides exit code. BTW, this patch ignores recursive comparison case, because: - there is no portable way for current while-read based implementation to return 1 at detecting changes - it isn't yet needed to replace direct "diff -r" invocation by pdiff for portability diff --git a/tests/pdiff b/tests/pdiff --- a/tests/pdiff +++ b/tests/pdiff @@ -41,6 +41,9 @@ filediff(){ diff -u "$file1" "$file2" | sed "s@^--- /dev/null\(.*\)\$@--- $1\1@" | sed "s@^\+\+\+ /dev/null\(.*\)\$@+++ $2\1@" + + # in this case, files differ from each other + return 1 } if test -d "$1" -o -d "$2"; then @@ -53,6 +56,14 @@ if test -d "$1" -o -d "$2"; then while read file; do filediff "$1/$file" "$2/$file" "diff -Nru $1/$file $2/$file" done + + # TODO: there is no portable way for current while-read based + # implementation to return 1 at detecting changes. + # + # On bash and dash, assignment to variable inside while-block + # doesn't affect outside, because inside while-block is executed + # in sub-shell. BTW, it affects outside while-block on ksh (as sh + # on Solaris). else filediff "$1" "$2" fi