Module Name: src Committed By: rillig Date: Wed Aug 17 20:10:29 UTC 2022
Modified Files: src/usr.bin/make: compat.c make.c src/usr.bin/make/unit-tests: opt-query.exp opt-query.mk Log Message: make: fix exit status for '-q' (since 1994) To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/usr.bin/make/compat.c cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/make.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-query.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-query.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.240 src/usr.bin/make/compat.c:1.241 --- src/usr.bin/make/compat.c:1.240 Sat May 7 17:49:47 2022 +++ src/usr.bin/make/compat.c Wed Aug 17 20:10:29 2022 @@ -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 @@ MakeUnmade(GNode *gn, GNode *pgn) * to tell him/her "yes". */ DEBUG0(MAKE, "out-of-date.\n"); - if (opts.query) + if (opts.query && gn != Targ_GetEndNode()) exit(1); /* Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.255 src/usr.bin/make/make.c:1.256 --- src/usr.bin/make/make.c:1.255 Sat May 7 17:49:47 2022 +++ src/usr.bin/make/make.c Wed Aug 17 20:10:29 2022 @@ -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 @@ MakeStartJobs(void) 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; Index: src/usr.bin/make/unit-tests/opt-query.exp diff -u src/usr.bin/make/unit-tests/opt-query.exp:1.3 src/usr.bin/make/unit-tests/opt-query.exp:1.4 --- src/usr.bin/make/unit-tests/opt-query.exp:1.3 Wed Aug 17 20:05:41 2022 +++ src/usr.bin/make/unit-tests/opt-query.exp Wed Aug 17 20:10:29 2022 @@ -7,7 +7,7 @@ opt-query-file.out-of-date in compat mod 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 @@ Making opt-query-file.out-of-date in job 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 Index: src/usr.bin/make/unit-tests/opt-query.mk diff -u src/usr.bin/make/unit-tests/opt-query.mk:1.5 src/usr.bin/make/unit-tests/opt-query.mk:1.6 --- src/usr.bin/make/unit-tests/opt-query.mk:1.5 Wed Aug 17 20:05:41 2022 +++ src/usr.bin/make/unit-tests/opt-query.mk Wed Aug 17 20:10:29 2022 @@ -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 @@ all: .PHONY variants cleanup _!= 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 @@ variants: .PHONY || 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 @@ variants: .PHONY . 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