summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c3
-rw-r--r--bin/sh/var.c8
-rw-r--r--bin/sh/var.h3
3 files changed, 9 insertions, 5 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 25c3fcf..14dd15f 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -997,8 +997,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
*/
if (argc == 0 && !(flags & EV_BACKCMD))
cmdentry.special = 1;
- if (cmdentry.special)
- listsetvar(cmdenviron);
+ listsetvar(cmdenviron, cmdentry.special ? 0 : VNOSET);
if (argc > 0)
bltinsetlocale();
commandname = argv[0];
diff --git a/bin/sh/var.c b/bin/sh/var.c
index 6c0618f..e841647 100644
--- a/bin/sh/var.c
+++ b/bin/sh/var.c
@@ -333,6 +333,8 @@ setvareq(char *s, int flags)
len = strchr(s, '=') - s;
error("%.*s: is read only", len, s);
}
+ if (flags & VNOSET)
+ return;
INTOFF;
if (vp->func && (flags & VNOFUNC) == 0)
@@ -365,6 +367,8 @@ setvareq(char *s, int flags)
}
}
/* not found */
+ if (flags & VNOSET)
+ return;
vp = ckmalloc(sizeof (*vp));
vp->flags = flags;
vp->text = s;
@@ -386,13 +390,13 @@ setvareq(char *s, int flags)
*/
void
-listsetvar(struct strlist *list)
+listsetvar(struct strlist *list, int flags)
{
struct strlist *lp;
INTOFF;
for (lp = list ; lp ; lp = lp->next) {
- setvareq(savestr(lp->text), 0);
+ setvareq(savestr(lp->text), flags);
}
INTON;
}
diff --git a/bin/sh/var.h b/bin/sh/var.h
index 1ec707b..775db41 100644
--- a/bin/sh/var.h
+++ b/bin/sh/var.h
@@ -45,6 +45,7 @@
#define VSTACK 0x10 /* text is allocated on the stack */
#define VUNSET 0x20 /* the variable is not set */
#define VNOFUNC 0x40 /* don't call the callback function */
+#define VNOSET 0x80 /* do not set variable - just readonly test */
struct var {
@@ -106,7 +107,7 @@ void initvar(void);
void setvar(const char *, const char *, int);
void setvareq(char *, int);
struct strlist;
-void listsetvar(struct strlist *);
+void listsetvar(struct strlist *, int);
char *lookupvar(const char *);
char *bltinlookup(const char *, int);
void bltinsetlocale(void);
OpenPOWER on IntegriCloud