summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--configure.ac2
-rw-r--r--hash.c35
-rw-r--r--main.c1
-rw-r--r--rc.h1
-rw-r--r--var.c1
6 files changed, 35 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index a8cf944..19d5506 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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)
diff --git a/hash.c b/hash.c
index 9b8c901..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", "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;
}
diff --git a/main.c b/main.c
index fd373e0..6ce7317 100644
--- a/main.c
+++ b/main.c
@@ -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);
diff --git a/rc.h b/rc.h
index fd3fc27..7b58010 100644
--- a/rc.h
+++ b/rc.h
@@ -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);
diff --git a/var.c b/var.c
index 0fa79c4..83c5ff9 100644
--- a/var.c
+++ b/var.c
@@ -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);