Ævar Arnfjörð Bjarmason wrote:
The clever for-loop (which I blindly copied from Junio)
You did not copy his “return” statement, though. :)
quoted hunk ↗ jump to hunk
+++ b/t/test-lib.sh
@@ -337,15 +337,30 @@ test_have_prereq () {
IFS=,
set -- $*
IFS=$save_IFS
+
+ total_prereq=0
+ ok_prereq=0
+ missing_prereq=
+
for prerequisite
do
+ total_prereq=$(($total_prereq + 1))
case $satisfied in
*" $prerequisite "*)
- : yes, have it ;;
+ ok_prereq=$(($ok_prereq + 1))
+ ;;
*)
- ! : nope ;;
+ # Keep a list of missing prerequisites
+ if test -z "$missing_prereq"
+ then
+ missing_prereq=$prerequisite
+ else
+ missing_prereq="$prerequisite,$missing_prereq"
+ fi
esac
done
+
+ test $total_prereq = $ok_prereq
}
Wouldn’t
- ! : nope ;;
+ return 1 ;;
be simpler?
This and a small cleanup, including a test that catches this, are at
http://thread.gmane.org/gmane.comp.version-control.git/152814/focus=152875
Hope that helps,
Jonathan