From 2e67f638ea031ce0138891b6356806b463f5e9af Mon Sep 17 00:00:00 2001 From: Toby Goodwin Date: Wed, 22 May 2002 14:25:10 +0100 Subject: candidate: rc-1.6c7 --- hash.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 16971ef..3f65ad8 100644 --- a/hash.c +++ b/hash.c @@ -228,14 +228,37 @@ extern void initenv(char **envp) { } } +static char *neverexport[] = { + "apid", "apids", "bqstatus", "cdpath", "home", + "ifs", "path", "pid", "status", "*" +}; + +/* for a few variables that have default values, we export them only +if they've been explicitly set; maybeexport[n].flag is TRUE if this +has occurred. */ +struct nameflag { + char *name; + bool flag; +}; +static struct nameflag maybeexport[] = { + { "prompt", FALSE }, + { "version", FALSE } +}; + +void set_exportable(char *s, bool b) { + int i; + for (i = 0; i < arraysize(maybeexport); ++i) + if (maybeexport[i].flag != b && streq(s, maybeexport[i].name)) + maybeexport[i].flag = b; +} + static bool var_exportable(char *s) { - static char *notforexport[] = { - "apid", "apids", "cdpath", "home", "ifs", - "path", "pid", "version", "*" - }; int i; - for (i = 0; i < arraysize(notforexport); i++) - if (streq(s, notforexport[i])) + for (i = 0; i < arraysize(neverexport); i++) + if (streq(s, neverexport[i])) + return FALSE; + for (i = 0; i < arraysize(maybeexport); i++) + if (maybeexport[i].flag == FALSE && streq(s, maybeexport[i].name)) return FALSE; return TRUE; } -- cgit v1.2.3