From cbc4c398d44760649fc29143cd80d3d2b15442ed Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 20 Jan 2013 12:44:50 +0000 Subject: sh: Remove mkinit's initialization routine. Instead, call the only init function left directly from main(). --- bin/sh/var.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'bin/sh/var.c') diff --git a/bin/sh/var.c b/bin/sh/var.c index 48a0dc5..3f29a48 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -146,29 +146,11 @@ static int varequal(const char *, const char *); static struct var *find_var(const char *, struct var ***, int *); static int localevar(const char *); -/* - * Initialize the variable symbol tables and import the environment. - */ - -#ifdef mkinit -INCLUDE "var.h" -MKINIT char **environ; -INIT { - char **envp; - - initvar(); - for (envp = environ ; *envp ; envp++) { - if (strchr(*envp, '=')) { - setvareq(*envp, VEXPORT|VTEXTFIXED); - } - } -} -#endif - +extern char **environ; /* - * This routine initializes the builtin variables. It is called when the - * shell is initialized. + * This routine initializes the builtin variables and imports the environment. + * It is called when the shell is initialized. */ void @@ -178,6 +160,7 @@ initvar(void) const struct varinit *ip; struct var *vp; struct var **vpp; + char **envp; for (ip = varinit ; (vp = ip->var) != NULL ; ip++) { if (find_var(ip->text, &vpp, &vp->name_len) != NULL) @@ -201,6 +184,11 @@ initvar(void) fmtstr(ppid, sizeof(ppid), "%d", (int)getppid()); setvarsafe("PPID", ppid, 0); } + for (envp = environ ; *envp ; envp++) { + if (strchr(*envp, '=')) { + setvareq(*envp, VEXPORT|VTEXTFIXED); + } + } } /* @@ -356,7 +344,7 @@ setvareq(char *s, int flags) * a regular variable function callback, but why bother? * * Note: this assumes iflag is not set to 1 initially. - * As part of init(), this is called before arguments + * As part of initvar(), this is called before arguments * are looked at. */ if ((vp == &vmpath || (vp == &vmail && ! mpathset())) && -- cgit v1.1