Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make If commandShell hasErrCtl is true, set shellErr...



details:   https://anonhg.NetBSD.org/src/rev/720136c9a63b
branches:  trunk
changeset: 787830:720136c9a63b
user:      sjg <sjg%NetBSD.org@localhost>
date:      Fri Jul 05 22:14:56 2013 +0000

description:
If commandShell hasErrCtl is true, set shellErrFlag for use by
CompatRunCommand() so that behavior in jobs and compat mode
remains consistent.

diffstat:

 usr.bin/make/compat.c |  23 ++++++++++++++---------
 usr.bin/make/job.c    |  27 ++++++++++++++++++++++++---
 usr.bin/make/job.h    |   3 ++-
 3 files changed, 40 insertions(+), 13 deletions(-)

diffs (141 lines):

diff -r 46251839ea18 -r 720136c9a63b usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Fri Jul 05 20:40:20 2013 +0000
+++ b/usr.bin/make/compat.c     Fri Jul 05 22:14:56 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $  */
+/*     $NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c   8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -329,18 +329,23 @@
         * We need to pass the command off to the shell, typically
         * because the command contains a "meta" character.
         */
-       static const char *shargv[4];
+       static const char *shargv[5];
+       int shargc;
 
-       shargv[0] = shellPath;
+       shargc = 0;
+       shargv[shargc++] = shellPath;
        /*
         * The following work for any of the builtin shell specs.
         */
+       if (shellErrFlag) {
+           shargv[shargc++] = shellErrFlag;
+       }
        if (DEBUG(SHELL))
-               shargv[1] = "-xc";
+               shargv[shargc++] = "-xc";
        else
-               shargv[1] = "-c";
-       shargv[2] = cmd;
-       shargv[3] = NULL;
+               shargv[shargc++] = "-c";
+       shargv[shargc++] = cmd;
+       shargv[shargc++] = NULL;
        av = shargv;
        argc = 0;
        bp = NULL;
diff -r 46251839ea18 -r 720136c9a63b usr.bin/make/job.c
--- a/usr.bin/make/job.c        Fri Jul 05 20:40:20 2013 +0000
+++ b/usr.bin/make/job.c        Fri Jul 05 22:14:56 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $    */
+/*     $NetBSD: job.c,v 1.174 2013/07/05 22:14:56 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.174 2013/07/05 22:14:56 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.174 2013/07/05 22:14:56 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -300,6 +300,7 @@
 const char *shellPath = NULL,                    /* full pathname of
                                                   * executable image */
            *shellName = NULL;                    /* last component of shell */
+char *shellErrFlag = NULL;
 static const char *shellArgv = NULL;             /* Custom shell args */
 
 
@@ -2136,6 +2137,24 @@
     if (commandShell->echo == NULL) {
        commandShell->echo = "";
     }
+    if (commandShell->hasErrCtl && *commandShell->exit) {
+       if (shellErrFlag &&
+           strcmp(commandShell->exit, &shellErrFlag[1]) != 0) {
+           free(shellErrFlag);
+           shellErrFlag = NULL;
+       }
+       if (!shellErrFlag) {
+           int n = strlen(commandShell->exit) + 2;
+
+           shellErrFlag = bmake_malloc(n);
+           if (shellErrFlag) {
+               snprintf(shellErrFlag, n, "-%s", commandShell->exit);
+           }
+       }
+    } else if (shellErrFlag) {
+       free(shellErrFlag);
+       shellErrFlag = NULL;
+    }
 }
 
 /*-
@@ -2480,6 +2499,8 @@
            commandShell = bmake_malloc(sizeof(Shell));
            *commandShell = newShell;
        }
+       /* this will take care of shellErrFlag */
+       Shell_Init();
     }
 
     if (commandShell->echoOn && commandShell->echoOff) {
diff -r 46251839ea18 -r 720136c9a63b usr.bin/make/job.h
--- a/usr.bin/make/job.h        Fri Jul 05 20:40:20 2013 +0000
+++ b/usr.bin/make/job.h        Fri Jul 05 22:14:56 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.h,v 1.41 2013/03/05 22:01:44 christos Exp $        */
+/*     $NetBSD: job.h,v 1.42 2013/07/05 22:14:56 sjg Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -243,6 +243,7 @@
 
 extern const char *shellPath;
 extern const char *shellName;
+extern char *shellErrFlag;
 
 extern int     jobTokensRunning; /* tokens currently "out" */
 extern int     maxJobs;        /* Max jobs we can run */



Home | Main Index | Thread Index | Old Index