Fri Jan 29 23:45:35 2021 UTC ()
make(1): explain seemingly redundant condition in jobs mode


(rillig)
diff -r1.401 -r1.402 src/usr.bin/make/job.c

cvs diff -r1.401 -r1.402 src/usr.bin/make/job.c (expand / switch to unified diff)

--- src/usr.bin/make/job.c 2021/01/29 23:33:24 1.401
+++ src/usr.bin/make/job.c 2021/01/29 23:45:35 1.402
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: job.c,v 1.401 2021/01/29 23:33:24 rillig Exp $ */ 1/* $NetBSD: job.c,v 1.402 2021/01/29 23:45:35 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -133,27 +133,27 @@ @@ -133,27 +133,27 @@
133#ifndef USE_SELECT 133#ifndef USE_SELECT
134#include <poll.h> 134#include <poll.h>
135#endif 135#endif
136#include <signal.h> 136#include <signal.h>
137#include <utime.h> 137#include <utime.h>
138 138
139#include "make.h" 139#include "make.h"
140#include "dir.h" 140#include "dir.h"
141#include "job.h" 141#include "job.h"
142#include "pathnames.h" 142#include "pathnames.h"
143#include "trace.h" 143#include "trace.h"
144 144
145/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ 145/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
146MAKE_RCSID("$NetBSD: job.c,v 1.401 2021/01/29 23:33:24 rillig Exp $"); 146MAKE_RCSID("$NetBSD: job.c,v 1.402 2021/01/29 23:45:35 rillig Exp $");
147 147
148/* 148/*
149 * A shell defines how the commands are run. All commands for a target are 149 * A shell defines how the commands are run. All commands for a target are
150 * written into a single file, which is then given to the shell to execute 150 * written into a single file, which is then given to the shell to execute
151 * the commands from it. The commands are written to the file using a few 151 * the commands from it. The commands are written to the file using a few
152 * templates for echo control and error control. 152 * templates for echo control and error control.
153 * 153 *
154 * The name of the shell is the basename for the predefined shells, such as 154 * The name of the shell is the basename for the predefined shells, such as
155 * "sh", "csh", "bash". For custom shells, it is the full pathname, and its 155 * "sh", "csh", "bash". For custom shells, it is the full pathname, and its
156 * basename is used to select the type of shell; the longest match wins. 156 * basename is used to select the type of shell; the longest match wins.
157 * So /usr/pkg/bin/bash has type sh, /usr/local/bin/tcsh has type csh. 157 * So /usr/pkg/bin/bash has type sh, /usr/local/bin/tcsh has type csh.
158 * 158 *
159 * The echoing of command lines is controlled using hasEchoCtl, echoOff, 159 * The echoing of command lines is controlled using hasEchoCtl, echoOff,
@@ -1662,29 +1662,31 @@ JobStart(GNode *gn, Boolean special) @@ -1662,29 +1662,31 @@ JobStart(GNode *gn, Boolean special)
1662 job->inPollfd = NULL; 1662 job->inPollfd = NULL;
1663 /* 1663 /*
1664 * If the -n flag wasn't given, we open up OUR (not the child's) 1664 * If the -n flag wasn't given, we open up OUR (not the child's)
1665 * temporary file to stuff commands in it. The thing is rd/wr so 1665 * temporary file to stuff commands in it. The thing is rd/wr so
1666 * we don't need to reopen it to feed it to the shell. If the -n 1666 * we don't need to reopen it to feed it to the shell. If the -n
1667 * flag *was* given, we just set the file to be stdout. Cute, huh? 1667 * flag *was* given, we just set the file to be stdout. Cute, huh?
1668 */ 1668 */
1669 if (Lst_IsEmpty(&gn->commands)) { 1669 if (Lst_IsEmpty(&gn->commands)) {
1670 job->cmdFILE = stdout; 1670 job->cmdFILE = stdout;
1671 run = FALSE; 1671 run = FALSE;
1672 } else if (((gn->type & OP_MAKE) && !opts.noRecursiveExecute) || 1672 } else if (((gn->type & OP_MAKE) && !opts.noRecursiveExecute) ||
1673 (!opts.noExecute && !opts.touchFlag)) { 1673 (!opts.noExecute && !opts.touchFlag)) {
1674 /* 1674 /*
1675 * XXX: The above conditions seem needlessly repeated but 1675 * The above conditions look very similar to
1676 * are subtly different. 1676 * GNode_ShouldExecute but are subtly different.
 1677 * They prevent that .MAKE targets are touched.
1677 */ 1678 */
 1679
1678 JobWriteShellCommands(job, gn, cmdsOK, &run); 1680 JobWriteShellCommands(job, gn, cmdsOK, &run);
1679 (void)fflush(job->cmdFILE); 1681 (void)fflush(job->cmdFILE);
1680 } else if (!GNode_ShouldExecute(gn)) { 1682 } else if (!GNode_ShouldExecute(gn)) {
1681 /* 1683 /*
1682 * Not executing anything -- just print all the commands to 1684 * Not executing anything -- just print all the commands to
1683 * stdout in one fell swoop. This will still set up 1685 * stdout in one fell swoop. This will still set up
1684 * job->tailCmds correctly. 1686 * job->tailCmds correctly.
1685 */ 1687 */
1686 SwitchOutputTo(gn); 1688 SwitchOutputTo(gn);
1687 job->cmdFILE = stdout; 1689 job->cmdFILE = stdout;
1688 /* 1690 /*
1689 * Only print the commands if they're ok, but don't die if 1691 * Only print the commands if they're ok, but don't die if
1690 * they're not -- just let the user know they're bad and 1692 * they're not -- just let the user know they're bad and