summaryrefslogtreecommitdiffstats
path: root/bin/sh/var.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-01-01 13:26:18 +0000
committerjilles <jilles@FreeBSD.org>2011-01-01 13:26:18 +0000
commit939106871155409dce420e35c6794821dd375a48 (patch)
tree9ba2056874948170151c7134c7d81e6ce37af27b /bin/sh/var.c
parent8229c0275d7cf8c5a2cd1e09ddcc3c74e9fafcfb (diff)
downloadFreeBSD-src-939106871155409dce420e35c6794821dd375a48.zip
FreeBSD-src-939106871155409dce420e35c6794821dd375a48.tar.gz
sh: Check readonly status for assignments on regular builtins.
An error message is written, the builtin is not executed, nonzero exit status is returned but the shell does not abort. This was already checked for special builtins and external commands, with the same consequences except that the shell aborts for special builtins. Obtained from: NetBSD
Diffstat (limited to 'bin/sh/var.c')
-rw-r--r--bin/sh/var.c8
1 files changed, 6 insertions, 2 deletions
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;
}
OpenPOWER on IntegriCloud