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(1): extract UseShell from Compat_RunCommand



details:   https://anonhg.NetBSD.org/src/rev/c311f6ca4775
branches:  trunk
changeset: 957869:c311f6ca4775
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 13 16:14:40 2020 +0000

description:
make(1): extract UseShell from Compat_RunCommand

diffstat:

 usr.bin/make/compat.c |  53 +++++++++++++++++++++++++++-----------------------
 1 files changed, 29 insertions(+), 24 deletions(-)

diffs (81 lines):

diff -r 54049894e35b -r c311f6ca4775 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sun Dec 13 08:23:52 2020 +0000
+++ b/usr.bin/make/compat.c     Sun Dec 13 16:14:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.208 2020/12/12 18:53:53 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.209 2020/12/13 16:14:40 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.208 2020/12/12 18:53:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.209 2020/12/13 16:14:40 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -180,6 +180,32 @@
        debug_printf("\n");
 }
 
+static Boolean
+UseShell(const char *cmd MAKE_ATTR_UNUSED)
+{
+#if !defined(MAKE_NATIVE)
+       /*
+        * In a non-native build, the host environment might be weird enough
+        * that it's necessary to go through a shell to get the correct
+        * behaviour.  Or perhaps the shell has been replaced with something
+        * that does extra logging, and that should not be bypassed.
+        */
+       return TRUE;
+#else
+       /*
+        * Search for meta characters in the command. If there are no meta
+        * characters, there's no need to execute a shell to execute the
+        * command.
+        *
+        * Additionally variable assignments and empty commands
+        * go to the shell. Therefore treat '=' and ':' like shell
+        * meta characters as documented in make(1).
+        */
+
+       return needshell(cmd);
+#endif
+}
+
 /* Execute the next command for a target. If the command returns an error,
  * the node's made field is set to ERROR and creation stops.
  *
@@ -264,28 +290,7 @@
        if (cmd[0] == '\0')
                return 0;
 
-#if !defined(MAKE_NATIVE)
-       /*
-        * In a non-native build, the host environment might be weird enough
-        * that it's necessary to go through a shell to get the correct
-        * behaviour.  Or perhaps the shell has been replaced with something
-        * that does extra logging, and that should not be bypassed.
-        */
-       useShell = TRUE;
-#else
-       /*
-        * Search for meta characters in the command. If there are no meta
-        * characters, there's no need to execute a shell to execute the
-        * command.
-        *
-        * Additionally variable assignments and empty commands
-        * go to the shell. Therefore treat '=' and ':' like shell
-        * meta characters as documented in make(1).
-        */
-
-       useShell = needshell(cmd);
-#endif
-
+       useShell = UseShell(cmd);
        /*
         * Print the command before echoing if we're not supposed to be quiet
         * for this one. We also print the command if -n given.



Home | Main Index | Thread Index | Old Index