Module Name: src
Committed By: sjg
Date: Fri Jul 5 22:14:56 UTC 2013
Modified Files:
src/usr.bin/make: compat.c job.c job.h
Log Message:
If commandShell hasErrCtl is true, set shellErrFlag for use by
CompatRunCommand() so that behavior in jobs and compat mode
remains consistent.
To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/make/compat.c
cvs rdiff -u -r1.173 -r1.174 src/usr.bin/make/job.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/job.h
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.91 src/usr.bin/make/compat.c:1.92
--- src/usr.bin/make/compat.c:1.91 Fri Jan 25 02:01:10 2013
+++ src/usr.bin/make/compat.c Fri Jul 5 22:14:56 2013
@@ -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 @@ again:
* 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;
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.173 src/usr.bin/make/job.c:1.174
--- src/usr.bin/make/job.c:1.173 Wed Jun 5 03:59:43 2013
+++ src/usr.bin/make/job.c Fri Jul 5 22:14:56 2013
@@ -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 @@ static Shell *commandShell = &shells[DEF
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 @@ Shell_Init(void)
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 @@ Job_ParseShell(char *line)
commandShell = bmake_malloc(sizeof(Shell));
*commandShell = newShell;
}
+ /* this will take care of shellErrFlag */
+ Shell_Init();
}
if (commandShell->echoOn && commandShell->echoOff) {
Index: src/usr.bin/make/job.h
diff -u src/usr.bin/make/job.h:1.41 src/usr.bin/make/job.h:1.42
--- src/usr.bin/make/job.h:1.41 Tue Mar 5 22:01:44 2013
+++ src/usr.bin/make/job.h Fri Jul 5 22:14:56 2013
@@ -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 @@ typedef struct Shell {
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 */