Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: fix exit status for '-q' (since 1994)



details:   https://anonhg.NetBSD.org/src/rev/9e3fd43405ae
branches:  trunk
changeset: 369447:9e3fd43405ae
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Aug 17 20:10:29 2022 +0000

description:
make: fix exit status for '-q' (since 1994)

diffstat:

 usr.bin/make/compat.c                 |   6 +++---
 usr.bin/make/make.c                   |   6 +++---
 usr.bin/make/unit-tests/opt-query.exp |   4 ++--
 usr.bin/make/unit-tests/opt-query.mk  |  18 ++++++++----------
 4 files changed, 16 insertions(+), 18 deletions(-)

diffs (124 lines):

diff -r 269ba4447480 -r 9e3fd43405ae usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Wed Aug 17 20:05:41 2022 +0000
+++ b/usr.bin/make/compat.c     Wed Aug 17 20:10:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.240 2022/05/07 17:49:47 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.241 2022/08/17 20:10:29 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.240 2022/05/07 17:49:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.241 2022/08/17 20:10:29 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -570,7 +570,7 @@
         * to tell him/her "yes".
         */
        DEBUG0(MAKE, "out-of-date.\n");
-       if (opts.query)
+       if (opts.query && gn != Targ_GetEndNode())
                exit(1);
 
        /*
diff -r 269ba4447480 -r 9e3fd43405ae usr.bin/make/make.c
--- a/usr.bin/make/make.c       Wed Aug 17 20:05:41 2022 +0000
+++ b/usr.bin/make/make.c       Wed Aug 17 20:10:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.255 2022/05/07 17:49:47 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.256 2022/08/17 20:10:29 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -104,7 +104,7 @@
 #include "job.h"
 
 /*     "@(#)make.c     8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: make.c,v 1.255 2022/05/07 17:49:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.256 2022/08/17 20:10:29 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -1077,7 +1077,7 @@
                if (GNode_IsOODate(gn)) {
                        DEBUG0(MAKE, "out-of-date\n");
                        if (opts.query)
-                               return true;
+                               return strcmp(gn->name, ".MAIN") != 0;
                        GNode_SetLocalVars(gn);
                        Job_Make(gn);
                        have_token = false;
diff -r 269ba4447480 -r 9e3fd43405ae usr.bin/make/unit-tests/opt-query.exp
--- a/usr.bin/make/unit-tests/opt-query.exp     Wed Aug 17 20:05:41 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-query.exp     Wed Aug 17 20:10:29 2022 +0000
@@ -7,7 +7,7 @@
 
 Making opt-query-file.up-to-date in compat mode:
 `opt-query-file.up-to-date' is up to date.
-opt-query-file.up-to-date in compat mode: query status 1
+opt-query-file.up-to-date in compat mode: query status 0
 
 Making phony in compat mode:
 phony in compat mode: query status 1
@@ -16,7 +16,7 @@
 opt-query-file.out-of-date in jobs mode: query status 1
 
 Making opt-query-file.up-to-date in jobs mode:
-opt-query-file.up-to-date in jobs mode: query status 1
+opt-query-file.up-to-date in jobs mode: query status 0
 
 Making phony in jobs mode:
 phony in jobs mode: query status 1
diff -r 269ba4447480 -r 9e3fd43405ae usr.bin/make/unit-tests/opt-query.mk
--- a/usr.bin/make/unit-tests/opt-query.mk      Wed Aug 17 20:05:41 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-query.mk      Wed Aug 17 20:10:29 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: opt-query.mk,v 1.5 2022/08/17 20:05:41 rillig Exp $
+# $NetBSD: opt-query.mk,v 1.6 2022/08/17 20:10:29 rillig Exp $
 #
 # Tests for the -q command line option.
 #
@@ -24,6 +24,7 @@
 _!=    touch -f opt-query-file.up-to-date
 
 variants: .PHONY
+
 .  for target in commands
        @echo 'Making ${target}':
        @${MAKE} -r -f ${MAKEFILE} -q ${mode:Mjobs:%=-j1} ${target} PART=commands \
@@ -31,6 +32,7 @@
        || echo "${target}: query status $$?"
        @echo
 .  endfor
+
 .  for mode in compat jobs
 .    for target in opt-query-file.out-of-date opt-query-file.up-to-date phony
        @echo 'Making ${target} in ${mode} mode':
@@ -41,18 +43,14 @@
 .    endfor
 .  endfor
 
+# Between 1994 and before 2022-08-17, the exit status for '-q' was always 1,
+# the cause for that exit code varied over time though.
+#
 # expect: opt-query-file.out-of-date in compat mode: query status 1
-
-# FIXME: must be 0, not 1.
-# expect: opt-query-file.up-to-date in compat mode: query status 1
-
+# expect: opt-query-file.up-to-date in compat mode: query status 0
 # expect: phony in compat mode: query status 1
-
 # expect: opt-query-file.out-of-date in jobs mode: query status 1
-
-# FIXME: must be 0, not 1.
-# expect: opt-query-file.up-to-date in jobs mode: query status 1
-
+# expect: opt-query-file.up-to-date in jobs mode: query status 0
 # expect: phony in jobs mode: query status 1
 
 cleanup: .PHONY



Home | Main Index | Thread Index | Old Index