Module Name:    src
Committed By:   sjg
Date:           Sun Dec 24 16:48:30 UTC 2023

Modified Files:
        src/usr.bin/make: compat.c make.1
        src/usr.bin/make/unit-tests: shell-sh.mk

Log Message:
Compat_RunCommand call Shell_Init is shellPath is NULL

Since .SHELL is potentially used in compat mode as well,
the man page description should not imply it is only used in jobs mode.

Remove path="sh" from shell-sh unit-test - and it would have detected
this bug.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/usr.bin/make/compat.c
cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/make.1
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/shell-sh.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.248 src/usr.bin/make/compat.c:1.249
--- src/usr.bin/make/compat.c:1.248	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/compat.c	Sun Dec 24 16:48:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.248 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg 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.248 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -275,11 +275,9 @@ Compat_RunCommand(const char *cmdp, GNod
 			silent = !DEBUG(LOUD);
 		else if (*cmd == '-')
 			errCheck = false;
-		else if (*cmd == '+') {
+		else if (*cmd == '+')
 			doIt = true;
-			if (shellName == NULL)	/* we came here from jobs */
-				Shell_Init();
-		} else if (!ch_isspace(*cmd))
+		else if (!ch_isspace(*cmd))
 			/* Ignore whitespace for compatibility with gnu make */
 			break;
 		cmd++;
@@ -302,6 +300,9 @@ Compat_RunCommand(const char *cmdp, GNod
 
 	DEBUG1(JOB, "Execute: '%s'\n", cmd);
 
+	if (useShell && shellPath == NULL)
+		Shell_Init();		/* we need shellPath */
+
 	if (useShell) {
 		static const char *shargv[5];
 

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.371 src/usr.bin/make/make.1:1.372
--- src/usr.bin/make/make.1:1.371	Sun Sep 10 21:52:36 2023
+++ src/usr.bin/make/make.1	Sun Dec 24 16:48:30 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.371 2023/09/10 21:52:36 rillig Exp $
+.\"	$NetBSD: make.1,v 1.372 2023/12/24 16:48:30 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd September 9, 2023
+.Dd December 24, 2023
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -2522,7 +2522,7 @@ set the read-only attribute on the globa
 .It Ic .SHELL
 Sets the shell that
 .Nm
-uses to execute commands in jobs mode.
+uses to execute commands.
 The sources are a set of
 .Ar field\| Ns Cm \&= Ns Ar value
 pairs.

Index: src/usr.bin/make/unit-tests/shell-sh.mk
diff -u src/usr.bin/make/unit-tests/shell-sh.mk:1.1 src/usr.bin/make/unit-tests/shell-sh.mk:1.2
--- src/usr.bin/make/unit-tests/shell-sh.mk:1.1	Sat Oct  3 14:39:36 2020
+++ src/usr.bin/make/unit-tests/shell-sh.mk	Sun Dec 24 16:48:30 2023
@@ -1,9 +1,9 @@
-# $NetBSD: shell-sh.mk,v 1.1 2020/10/03 14:39:36 rillig Exp $
+# $NetBSD: shell-sh.mk,v 1.2 2023/12/24 16:48:30 sjg Exp $
 #
 # Tests for using a bourne shell for running the commands.
 # This is the default shell, so there's nothing surprising.
 
-.SHELL: name="sh" path="sh"
+.SHELL: name="sh"
 
 all:
 	: normal

Reply via email to