summaryrefslogtreecommitdiffstats
path: root/bin/sh/var.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-01-20 12:44:50 +0000
committerjilles <jilles@FreeBSD.org>2013-01-20 12:44:50 +0000
commitcbc4c398d44760649fc29143cd80d3d2b15442ed (patch)
treef54c8326998bb42465e5f36fa16e3ac63b79d8e0 /bin/sh/var.c
parente072d47ed32f3fa80eb1c091148c6dcbcc4bac1c (diff)
downloadFreeBSD-src-cbc4c398d44760649fc29143cd80d3d2b15442ed.zip
FreeBSD-src-cbc4c398d44760649fc29143cd80d3d2b15442ed.tar.gz
sh: Remove mkinit's initialization routine.
Instead, call the only init function left directly from main().
Diffstat (limited to 'bin/sh/var.c')
-rw-r--r--bin/sh/var.c32
1 files changed, 10 insertions, 22 deletions
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())) &&
OpenPOWER on IntegriCloud