[erlang-patches] erl -make should set exit code on failure

Magnus Henoch <>
Wed Mar 18 18:04:03 CET 2009


This is just something I need to get off my chest...

It always bothered me that "erl -make" would return exit code 0
regardless of whether the compilation succeeded or failed.  So here is a
patch (against R13A) that sets exit code 1 on failure.  I hope it will
be useful to someone.

--- otp_src_R13A/erts/etc/common/erlexec.c	2009/03/18 16:37:47	1.1
+++ otp_src_R13A/erts/etc/common/erlexec.c	2009/03/18 16:40:23	1.2
@@ -678,7 +678,7 @@
 		     * on itself here.  We'll avoid doing that.
 		     */
 		    if (strcmp(argv[i], "-make") == 0) {
-			add_args("-noshell", "-noinput", "-s", "make", "all", NULL);
+			add_args("-noshell", "-noinput", "-s", "make", "all_or_nothing", NULL);
 			add_Eargs("-B");
 			haltAfterwards = 1;
 			i = argc; /* Skip rest of command line */
--- otp_src_R13A/lib/tools/src/make.erl	2009/03/18 16:38:24	1.1
+++ otp_src_R13A/lib/tools/src/make.erl	2009/03/18 16:39:46	1.2
@@ -24,12 +24,20 @@
 %% If Emakefile is missing the current directory is used.
 -module(make).
 
--export([all/0,all/1,files/1,files/2]).
+-export([all_or_nothing/0,all/0,all/1,files/1,files/2]).
 
 -include_lib("kernel/include/file.hrl").
 
 -define(MakeOpts,[noexec,load,netload,noload]).
 
+all_or_nothing() ->
+    case all() of
+        up_to_date ->
+            up_to_date;
+        error ->
+            halt(1)
+    end.
+
 all() ->
     all([]).
 


-- 
Magnus Henoch, 
Erlang Training and Consulting
http://www.erlang-consulting.com/




More information about the erlang-patches mailing list