- #### POSIX diff should support -c.
- if diff -c "$1" "$2"; then
- test $# -lt 3 -o "$3" != 'keep first' && rm -f "$1"
- rm -f "$2"
+ first=$1; shift
+ second=$1; shift
+ keepfirst=
+ ignorespace=
+ while [ $# -gt 0 ]; do
+ case $1 in
+ 'keep first') keepfirst=1 ;;
+ 'ignore space') ignorespace=1 ;;
+ *) echo "$0: invalid check() argument \"$1\" in test suite" >&2 ;;
+ esac
+ shift
+ done
+
+ success=
+ if [ "$ignorespace" ]; then
+ #### POSIX diff should support -b.
+ diff -b "$first" "$second" >/dev/null && success=1
+ else
+ cmp -s "$first" "$second" && success=1
+ fi
+
+ if [ "$success" ]; then
+ [ "$keepfirst" ] || rm -f "$first"
+ rm -f "$second"