Fix a segfault by only constructing the prompt when we need to. If we don't
authorMatt Kraai <kraai@debian.org>
Fri, 5 Jan 2001 02:53:11 +0000 (02:53 -0000)
committerMatt Kraai <kraai@debian.org>
Fri, 5 Jan 2001 02:53:11 +0000 (02:53 -0000)
do this we will segfault processing /etc/.profile since cwd isn't yet set.

lash.c
sh.c
shell/lash.c

diff --git a/lash.c b/lash.c
index dd1d3aa5c37b9c2f58cc88f9a618e0ec65fddf62..3d54b439e7755a53a2b4020a7c0752c4d9e5427e 100644 (file)
--- a/lash.c
+++ b/lash.c
@@ -774,9 +774,9 @@ static int get_command(FILE * source, char *command)
                return 1;
        }
 
-       prompt_str = setup_prompt_string(shell_context);
-       
        if (source == stdin) {
+               prompt_str = setup_prompt_string(shell_context);
+       
 #ifdef BB_FEATURE_SH_COMMAND_EDITING
                /*
                ** enable command line editing only while a command line
diff --git a/sh.c b/sh.c
index dd1d3aa5c37b9c2f58cc88f9a618e0ec65fddf62..3d54b439e7755a53a2b4020a7c0752c4d9e5427e 100644 (file)
--- a/sh.c
+++ b/sh.c
@@ -774,9 +774,9 @@ static int get_command(FILE * source, char *command)
                return 1;
        }
 
-       prompt_str = setup_prompt_string(shell_context);
-       
        if (source == stdin) {
+               prompt_str = setup_prompt_string(shell_context);
+       
 #ifdef BB_FEATURE_SH_COMMAND_EDITING
                /*
                ** enable command line editing only while a command line
index dd1d3aa5c37b9c2f58cc88f9a618e0ec65fddf62..3d54b439e7755a53a2b4020a7c0752c4d9e5427e 100644 (file)
@@ -774,9 +774,9 @@ static int get_command(FILE * source, char *command)
                return 1;
        }
 
-       prompt_str = setup_prompt_string(shell_context);
-       
        if (source == stdin) {
+               prompt_str = setup_prompt_string(shell_context);
+       
 #ifdef BB_FEATURE_SH_COMMAND_EDITING
                /*
                ** enable command line editing only while a command line