Skip to content

Commit

Permalink
Introduce a 'noexport' variable, from es(1).
Browse files Browse the repository at this point in the history
Some variables are never exported to the environment, most of which are related
to the internal functioning of rc(1). This list was previously harcoded,
however later shells in the rc family (es, xs) included a 'noexport' variable,
which contained the name of variables which should never be exported to the
environment. This commit ports this 'noexport' feature to rc.
  • Loading branch information
sysvinit committed Sep 17, 2021
1 parent 0ccebac commit 84d4004
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 4 additions & 8 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ extern void initenv(char **envp) {
}
}

static char *neverexport[] = {
"apid", "apids", "bqstatus", "cdpath", "home",
"ifs", "path", "pid", "ppid", "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. */
Expand All @@ -255,12 +250,13 @@ void set_exportable(char *s, bool b) {

static bool var_exportable(char *s) {
int i;
for (i = 0; i < arraysize(neverexport); i++)
if (streq(s, neverexport[i]))
return FALSE;
List *noex;
for (i = 0; i < arraysize(maybeexport); i++)
if (maybeexport[i].flag == FALSE && streq(s, maybeexport[i].name))
return FALSE;
for (noex = varlookup("noexport"); noex != NULL; noex = noex->n)
if (streq(s, noex->w))
return FALSE;
return TRUE;
}

Expand Down
3 changes: 3 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ extern int main(int argc, char *argv[], char *envp[]) {
VERSION,
"$Release: @(#)" PACKAGE " " VERSION " " DESCRIPTION " $",
(void *)0 );
assigndefault("noexport",
"noexport", "apid", "apids", "bqstatus", "cdpath", "home",
"ifs", "path", "pid", "ppid", "status", "*", (void *)0);
initenv(envp);
initinput();
null[0] = NULL;
Expand Down

0 comments on commit 84d4004

Please sign in to comment.