aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-10-23 20:48:25 -0500
committerRob Landley <rob@landley.net>2020-10-23 20:48:25 -0500
commitc5793830331433f80ea7f9b07601679a6dae6e90 (patch)
treed2dcf499296499babf1ec66668070d60a9ec7f42
parentefcc4a1f6aa8207a5d89c0900f28c216e5d93cb0 (diff)
downloadtoybox-c5793830331433f80ea7f9b07601679a6dae6e90.tar.gz
Fix endless recursion bug on nommu for sh -c 'echo $(echo)'
-rw-r--r--toys/pending/sh.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 784c7a01..d3a9e59c 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -3189,7 +3189,7 @@ FILE *fpathopen(char *name)
void sh_main(void)
{
- char *new, *cc = TT.sh.c;
+ char *new, *cc = 0;
struct sh_function scratch;
int prompt = 0;
struct string_list *sl = 0;
@@ -3216,10 +3216,13 @@ void sh_main(void)
// if (!FLAG(noprofile)) { }
// Is this an interactive shell?
- if (FLAG(s) || (!FLAG(c) && !toys.optc)) TT.options |= OPT_S;
- if (FLAG(i) || (!FLAG(c) && (TT.options&OPT_S) && isatty(0)))
- TT.options |= OPT_I;
- if (FLAG(c)) TT.options |= OPT_C;
+ if (toys.stacktop) {
+ cc = TT.sh.c;
+ if (FLAG(s) || (!FLAG(c) && !toys.optc)) TT.options |= OPT_S;
+ if (FLAG(i) || (!FLAG(c) && (TT.options&OPT_S) && isatty(0)))
+ TT.options |= OPT_I;
+ if (FLAG(c)) TT.options |= OPT_C;
+ }
// Read environment for exports from parent shell. Note, calls run_sh()
// which blanks argument sections of TT and this, so parse everything