Move init of a bunch of globals into main so we are at least
authorEric Andersen <andersen@codepoet.org>
Wed, 16 May 2001 05:24:03 +0000 (05:24 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 16 May 2001 05:24:03 +0000 (05:24 -0000)
a bit more reentrant.
 -Erik

hush.c
shell/hush.c

diff --git a/hush.c b/hush.c
index 5a4966b07bada1e378210e3cce4772cc99bf6614..c938fb1e398491ba06caefe184a0bffd5ce93308 100644 (file)
--- a/hush.c
+++ b/hush.c
@@ -239,17 +239,17 @@ unsigned int shell_context;  /* Used in cmdedit.c to reset the
                               * context when someone hits ^C */
 
 /* "globals" within this file */
-static char *ifs=NULL;
+static char *ifs;
 static char map[256];
-static int fake_mode=0;
-static int interactive=0;
-static struct close_me *close_me_head = NULL;
+static int fake_mode;
+static int interactive;
+static struct close_me *close_me_head;
 static const char *cwd;
 static struct jobset *job_list;
-static unsigned int last_bg_pid=0;
+static unsigned int last_bg_pid;
 static char *PS1;
-static char *PS2 = "> ";
-static char **__shell_local_env = 0;
+static char *PS2;
+static char **__shell_local_env;
 
 #define B_CHUNK (100)
 #define B_NOSPAC 1
@@ -2511,7 +2511,16 @@ int shell_main(int argc, char **argv)
        int opt;
        FILE *input;
        struct jobset joblist_end = { NULL, NULL };
+
+       /* (re?) initialize globals */
+       ifs=NULL;
+       fake_mode=0;
+       interactive=0;
+       close_me_head = NULL;
        job_list = &joblist_end;
+       last_bg_pid=0;
+       PS2 = "> ";
+       __shell_local_env = 0;
 
        last_return_code=EXIT_SUCCESS;
 
index 5a4966b07bada1e378210e3cce4772cc99bf6614..c938fb1e398491ba06caefe184a0bffd5ce93308 100644 (file)
@@ -239,17 +239,17 @@ unsigned int shell_context;  /* Used in cmdedit.c to reset the
                               * context when someone hits ^C */
 
 /* "globals" within this file */
-static char *ifs=NULL;
+static char *ifs;
 static char map[256];
-static int fake_mode=0;
-static int interactive=0;
-static struct close_me *close_me_head = NULL;
+static int fake_mode;
+static int interactive;
+static struct close_me *close_me_head;
 static const char *cwd;
 static struct jobset *job_list;
-static unsigned int last_bg_pid=0;
+static unsigned int last_bg_pid;
 static char *PS1;
-static char *PS2 = "> ";
-static char **__shell_local_env = 0;
+static char *PS2;
+static char **__shell_local_env;
 
 #define B_CHUNK (100)
 #define B_NOSPAC 1
@@ -2511,7 +2511,16 @@ int shell_main(int argc, char **argv)
        int opt;
        FILE *input;
        struct jobset joblist_end = { NULL, NULL };
+
+       /* (re?) initialize globals */
+       ifs=NULL;
+       fake_mode=0;
+       interactive=0;
+       close_me_head = NULL;
        job_list = &joblist_end;
+       last_bg_pid=0;
+       PS2 = "> ";
+       __shell_local_env = 0;
 
        last_return_code=EXIT_SUCCESS;