Add .SHELL as read-only variable
The .SHELL variable represents the shellPath used to run scripts. Reviewed by: rillig, christos
This commit is contained in:
parent
18284a5949
commit
74eb567570
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: job.c,v 1.212 2020/08/22 15:43:32 rillig Exp $ */
|
||||
/* $NetBSD: job.c,v 1.213 2020/08/22 19:30:58 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.212 2020/08/22 15:43:32 rillig Exp $";
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.213 2020/08/22 19:30:58 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.212 2020/08/22 15:43:32 rillig Exp $");
|
||||
__RCSID("$NetBSD: job.c,v 1.213 2020/08/22 19:30:58 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -2201,6 +2201,7 @@ Shell_Init(void)
|
|||
#endif
|
||||
shellPath = str_concat3(_PATH_DEFSHELLDIR, "/", shellName);
|
||||
}
|
||||
Var_Set_with_flags(".SHELL", shellPath, VAR_CMD, VAR_SET_READONLY);
|
||||
if (commandShell->exit == NULL) {
|
||||
commandShell->exit = "";
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: make.1,v 1.287 2020/08/19 06:10:06 rillig Exp $
|
||||
.\" $NetBSD: make.1,v 1.288 2020/08/22 19:30:58 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 August 19, 2020
|
||||
.Dd August 22, 2020
|
||||
.Dt MAKE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -1140,6 +1140,9 @@ is set to the value of
|
|||
for all programs which
|
||||
.Nm
|
||||
executes.
|
||||
.It Ev .SHELL
|
||||
The pathname of the shell used to run target scripts.
|
||||
It is read-only.
|
||||
.It Ev .TARGETS
|
||||
The list of targets explicitly specified on the command line, if any.
|
||||
.It Ev VPATH
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nonints.h,v 1.95 2020/08/21 23:28:11 rillig Exp $ */
|
||||
/* $NetBSD: nonints.h,v 1.96 2020/08/22 19:30:58 sjg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -186,8 +186,15 @@ typedef enum {
|
|||
VARE_ASSIGN = 0x04
|
||||
} VarEvalFlags;
|
||||
|
||||
typedef enum {
|
||||
VAR_NO_EXPORT = 0x01, /* do not export */
|
||||
VAR_SET_READONLY = 0x02
|
||||
} VarSet_Flags;
|
||||
|
||||
|
||||
void Var_Delete(const char *, GNode *);
|
||||
void Var_Set(const char *, const char *, GNode *);
|
||||
void Var_Set_with_flags(const char *, const char *, GNode *, VarSet_Flags);
|
||||
void Var_Append(const char *, const char *, GNode *);
|
||||
Boolean Var_Exists(const char *, GNode *);
|
||||
const char *Var_Value(const char *, GNode *, char **);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
&=ampersand
|
||||
.MAKE.LEVEL.ENV=MAKELEVEL
|
||||
MAKELEVEL=1
|
||||
UT_DOLLAR=This is $UT_FU
|
||||
UT_FOO=foobar is fubar
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: var.c,v 1.456 2020/08/22 17:34:25 rillig Exp $ */
|
||||
/* $NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -69,14 +69,14 @@
|
|||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.456 2020/08/22 17:34:25 rillig Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: var.c,v 1.456 2020/08/22 17:34:25 rillig Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -229,7 +229,8 @@ typedef enum {
|
|||
* variable can then be resolved. */
|
||||
VAR_REEXPORT = 0x20,
|
||||
/* The variable came from command line. */
|
||||
VAR_FROM_CMD = 0x40
|
||||
VAR_FROM_CMD = 0x40,
|
||||
VAR_READONLY = 0x80
|
||||
} VarFlags;
|
||||
|
||||
ENUM_RTTI_7(VarFlags,
|
||||
|
@ -281,10 +282,6 @@ typedef enum {
|
|||
VARP_ANCHOR_END = 0x08 /* Match at end of word */
|
||||
} VarPatternFlags;
|
||||
|
||||
typedef enum {
|
||||
VAR_NO_EXPORT = 0x01 /* do not export */
|
||||
} VarSet_Flags;
|
||||
|
||||
#define BROPEN '{'
|
||||
#define BRCLOSE '}'
|
||||
#define PROPEN '('
|
||||
|
@ -346,6 +343,12 @@ VarFind(const char *name, GNode *ctxt, VarFindFlags flags)
|
|||
if (strcmp(name, ".PREFIX") == 0)
|
||||
name = PREFIX;
|
||||
break;
|
||||
case 'S':
|
||||
if (strcmp(name, ".SHELL") == 0 ) {
|
||||
if (!shellPath)
|
||||
Shell_Init();
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
if (strcmp(name, ".TARGET") == 0)
|
||||
name = TARGET;
|
||||
|
@ -771,7 +774,7 @@ Var_UnExport(const char *str)
|
|||
}
|
||||
|
||||
/* See Var_Set for documentation. */
|
||||
static void
|
||||
void
|
||||
Var_Set_with_flags(const char *name, const char *val, GNode *ctxt,
|
||||
VarSet_Flags flags)
|
||||
{
|
||||
|
@ -817,7 +820,16 @@ Var_Set_with_flags(const char *name, const char *val, GNode *ctxt,
|
|||
Var_Delete(name, VAR_GLOBAL);
|
||||
}
|
||||
VarAdd(name, val, ctxt);
|
||||
if (flags & VAR_SET_READONLY) {
|
||||
v = VarFind(name, ctxt, 0);
|
||||
v->flags |= VAR_READONLY;
|
||||
}
|
||||
} else {
|
||||
if ((v->flags & VAR_READONLY) && !(flags & VAR_SET_READONLY)) {
|
||||
VAR_DEBUG("%s:%s = %s ignored (read-only)\n",
|
||||
ctxt->name, name, val);
|
||||
goto out;
|
||||
}
|
||||
Buf_Empty(&v->val);
|
||||
if (val)
|
||||
Buf_AddStr(&v->val, val);
|
||||
|
@ -830,8 +842,9 @@ Var_Set_with_flags(const char *name, const char *val, GNode *ctxt,
|
|||
/*
|
||||
* Any variables given on the command line are automatically exported
|
||||
* to the environment (as per POSIX standard)
|
||||
* Other than internals.
|
||||
*/
|
||||
if (ctxt == VAR_CMD && !(flags & VAR_NO_EXPORT)) {
|
||||
if (ctxt == VAR_CMD && !(flags & VAR_NO_EXPORT) && name[0] != '.') {
|
||||
if (v == NULL) {
|
||||
/* we just added it */
|
||||
v = VarFind(name, ctxt, 0);
|
||||
|
|
Loading…
Reference in New Issue