aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-05-19 15:37:50 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-05-19 15:39:32 +0200
commit0c3601936915d3d625683388c62c561de96a47da (patch)
treeb427f860b4b43e2214a031589ecffa188a946ac9 /shell/hush.c
parent08fb82c80cf06b776822b8388c3863e7c5565a74 (diff)
downloadbusybox-0c3601936915d3d625683388c62c561de96a47da.tar.gz
hush: set default PS1/2 only if we interactive
"env - hush SCRIPT" invocation (that is, with empty environment) should not show PS1/2 in "set" output. function old new delta hush_main 1070 1075 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 629b7ff92..2b9abbdfd 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9888,14 +9888,6 @@ int hush_main(int argc, char **argv)
/* Export PWD */
set_pwd_var(SETFLAG_EXPORT);
-#if ENABLE_HUSH_INTERACTIVE && ENABLE_FEATURE_EDITING_FANCY_PROMPT
- /* Set (but not export) PS1/2 unless already set */
- if (!get_local_var_value("PS1"))
- set_local_var_from_halves("PS1", "\\w \\$ ");
- if (!get_local_var_value("PS2"))
- set_local_var_from_halves("PS2", "> ");
-#endif
-
#if BASH_HOSTNAME_VAR
/* Set (but not export) HOSTNAME unless already set */
if (!get_local_var_value("HOSTNAME")) {
@@ -9907,6 +9899,8 @@ int hush_main(int argc, char **argv)
/* IFS is not inherited from the parent environment */
set_local_var_from_halves("IFS", defifs);
+ /* PS1/PS2 are set later, if we determine that we are interactive */
+
/* bash also exports SHLVL and _,
* and sets (but doesn't export) the following variables:
* BASH=/bin/bash
@@ -10278,14 +10272,23 @@ int hush_main(int argc, char **argv)
* (--norc turns this off, --rcfile <file> overrides)
*/
- if (!ENABLE_FEATURE_SH_EXTRA_QUIET && G_interactive_fd) {
- /* note: ash and hush share this string */
- printf("\n\n%s %s\n"
- IF_HUSH_HELP("Enter 'help' for a list of built-in commands.\n")
- "\n",
- bb_banner,
- "hush - the humble shell"
- );
+ if (G_interactive_fd) {
+#if ENABLE_HUSH_INTERACTIVE && ENABLE_FEATURE_EDITING_FANCY_PROMPT
+ /* Set (but not export) PS1/2 unless already set */
+ if (!get_local_var_value("PS1"))
+ set_local_var_from_halves("PS1", "\\w \\$ ");
+ if (!get_local_var_value("PS2"))
+ set_local_var_from_halves("PS2", "> ");
+#endif
+ if (!ENABLE_FEATURE_SH_EXTRA_QUIET) {
+ /* note: ash and hush share this string */
+ printf("\n\n%s %s\n"
+ IF_HUSH_HELP("Enter 'help' for a list of built-in commands.\n")
+ "\n",
+ bb_banner,
+ "hush - the humble shell"
+ );
+ }
}
parse_and_run_file(hfopen(NULL)); /* stdin */