diff top/maint.mk @ 12325:444e305ec8cc

maint.mk: improve sc_prohibit_magic_number_exit * top/maint.mk (sc_prohibit_magic_number_exit): Tighten regexp so it does not match uses like System.exit(1). Add comments showing how to correct all offenders.
author Jim Meyering <meyering@redhat.com>
date Fri, 20 Nov 2009 13:24:24 +0100
parents 0c467c7c0132
children 1d8d8b72ddd8
line wrap: on
line diff
--- a/top/maint.mk	Thu Nov 19 09:12:34 2009 -0700
+++ b/top/maint.mk	Fri Nov 20 13:24:24 2009 +0100
@@ -157,8 +157,17 @@
 		1>&2; exit 1; } || :
 
 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
+# Convert all uses automatically, via these two commands:
+# git grep -l '\<exit *(1)' \
+#  | grep -vEf .x-sc_prohibit_magic_number_exit \
+#  | xargs --no-run-if-empty \
+#      perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
+# git grep -l '\<exit *(0)' \
+#  | grep -vEf .x-sc_prohibit_magic_number_exit \
+#  | xargs --no-run-if-empty \
+#      perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
 sc_prohibit_magic_number_exit:
-	@re='\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,'		\
+	@re='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,'	\
 	msg='use EXIT_* values rather than magic number'		\
 	  $(_prohibit_regexp)