]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: add syntax-check rule to help avoid misuse of EXIT_FAILURE
authorJim Meyering <meyering@redhat.com>
Tue, 3 Jul 2012 18:14:56 +0000 (20:14 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 3 Jul 2012 18:14:56 +0000 (20:14 +0200)
* cfg.mk (sc_some_programs_must_avoid_exit_failure): New rule,
to help us avoid using EXIT_FAILURE in programs like sort, ls, nohup,
timeout, env, etc. that use different exit codes in many cases.

cfg.mk

diff --git a/cfg.mk b/cfg.mk
index ef8a2c8b9a3ac7cce78cac9edccff118c710376c..6620eafd2ee9dc19df40d6209ee9ea71d0002fd5 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -319,6 +319,16 @@ sc_prohibit_test_backticks:
        halt='use $$(...), not `...` in tests/'                         \
          $(_sc_search_regexp)
 
+# Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
+# Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
+# In those programs, ensure that EXIT_FAILURE is not used by mistake.
+sc_some_programs_must_avoid_exit_failure:
+       @grep -nw EXIT_FAILURE                                          \
+           $$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' src)           \
+         | grep -vE '= EXIT_FAILURE|exit \(.* \?' | grep .             \
+           && { echo '$(ME): do not use EXIT_FAILURE in the above'     \
+                 1>&2; exit 1; } || :
+
 # Exempt the contents of any usage function from the following.
 _continued_string_col_1 = \
 s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}