From fe3a63fa6cdffa020e380d3e27cf0eb8f3b46b1f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 6 Sep 2016 09:42:33 +0100 Subject: 39181: Add PM_SINGLE and use for compstate. This flags that compstate (or any other special) can only have a single instance and an attempt to create a new one is an error. Given the very fiddly semantics of compstate any other usage seems pointless. No investigation yet of other variables that could use this. Note it's still possible to hide such variables; only instances that keep the special nature are affected. --- Src/builtin.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Src/builtin.c') diff --git a/Src/builtin.c b/Src/builtin.c index da453000c..3b82c9e7f 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2266,6 +2266,10 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), zerrnam(cname, "%s: restricted", pname); return pm; } + if (pm->node.flags & PM_SINGLE) { + zerrnam(cname, "%s: can only have a single instance", pname); + return pm; + } /* * For specials, we keep the same struct but zero everything. * Maybe it would be easier to create a new struct but copy -- cgit v1.2.3