diff options
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | hash.c | 35 | ||||
| -rw-r--r-- | main.c | 1 | ||||
| -rw-r--r-- | rc.h | 1 | ||||
| -rw-r--r-- | var.c | 1 |
6 files changed, 35 insertions, 8 deletions
@@ -771,6 +771,7 @@ Changes since rc-1.5b2 2002-04-03 - Feature: make $version less magical, and exportable. + Feature: make $version less magical, and exportable if it's changed + from its default value. Same for $prompt. Bug: make $bqstatus and $status not exportable. diff --git a/configure.ac b/configure.ac index 9729f63..d425740 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ dnl Automake stuff. dnl Use this one for snapshots... dnl AM_INIT_AUTOMAKE(rc, 1.6s`echo $RELDATE |sed 's/-//g'`) dnl ...and this one for releases -AM_INIT_AUTOMAKE(rc, 1.6c6) +AM_INIT_AUTOMAKE(rc, 1.6c7) AM_CONFIG_HEADER(config.h) @@ -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", "bqstatus", "cdpath", "home", "ifs", - "path", "pid", "status", "*" - }; 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; } @@ -113,6 +113,7 @@ static void assigndefault(char *name,...) { for (l = NULL; (v = va_arg(ap, char *)) != NULL;) l = append(l, word(v, NULL)); varassign(name, l, FALSE); + set_exportable(name, FALSE); if (streq(name, "path")) alias(name, l, FALSE); va_end(ap); @@ -251,6 +251,7 @@ extern void fnassign_string(char *); extern void fnrm(char *); extern void initenv(char **); extern void inithash(void); +extern void set_exportable(char *, bool); extern void setsigdefaults(bool); extern void inithandler(void); extern void varassign(char *, List *, bool); @@ -18,6 +18,7 @@ extern void varassign(char *name, List *def, bool stack) { new = get_var_place(name, stack); new->def = newdef; new->extdef = NULL; + set_exportable(name, TRUE); #if READLINE if (interactive && (streq(name, "TERM") || streq(name, "TERMCAP"))) rl_reset_terminal(NULL); |