aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-04-03 07:34:19 -0500
committerRob Landley <rob@landley.net>2021-04-03 07:34:19 -0500
commit6a73a3c9ee4b9e17704c368c27d0af34d785fa53 (patch)
treea8e03367058787428a93c2724531555011dd6c98
parent4e2a912dac1f4a94ac81ea9c894de3d385563a2a (diff)
downloadtoybox-6a73a3c9ee4b9e17704c368c27d0af34d785fa53.tar.gz
Fix the next test.
-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 06dff9cf..0f26f3fc 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -865,7 +865,7 @@ static int end_function(int funconly)
static int run_subshell(char *str, int len)
{
pid_t pid;
-//dprintf(2, "%d run_subshell %.*s\n", getpid(), len, str);
+//dprintf(2, "%d run_subshell %.*s\n", getpid(), len, str); debug_show_fds();
// The with-mmu path is significantly faster.
if (CFG_TOYBOX_FORK) {
if ((pid = fork())<0) perror_msg("fork");
@@ -2290,7 +2290,10 @@ static struct sh_process *run_command(void)
struct sh_vars *vv;
// If prefix assignment, create temp function context to hold vars
- if (!(persist = envlen==arg->c || TT.ff->blk->pipe)) call_function();
+ if (envlen!=arg->c || TT.ff->blk->pipe!=-1) {
+ call_function();
+ persist = 0;
+ }
for (; jj<envlen && !pp; jj++) {
// TODO this is localize(), merge with export() and local_main
s = arg->v[jj];
@@ -2313,13 +2316,13 @@ static struct sh_process *run_command(void)
if (pp->exit || envlen==arg->c) s = 0; // leave $_ alone
else if (!pp->arg.v) s = ""; // nothing to do but blank $_
else {
- struct toy_list *tl = toy_find(pp->arg.v[envlen]);
+ struct toy_list *tl = toy_find(*pp->arg.v);
jj = tl ? tl->flags : 0;
TT.pp = pp;
s = pp->arg.v[pp->arg.c-1];
sss = pp->arg.v[pp->arg.c];
-//dprintf(2, "%d run command %s\n", getpid(), pp->arg.v[envlen]);
+//dprintf(2, "%d run command %s\n", getpid(), *pp->arg.v); debug_show_fds();
// TODO handle ((math)): else if (!strcmp(*pp->arg.v, "(("))
// TODO: call functions() FUNCTION
// TODO what about "echo | x=1 | export fruit", must subshell? Test this.
@@ -3329,7 +3332,7 @@ int do_source(char *name, FILE *ff)
do {
if ((void *)1 == (new = get_next_line(ff, more+1))) goto is_binary;
-//dprintf(2, "%d getline from %p %s\n", getpid(), ff, new);
+//dprintf(2, "%d getline from %p %s\n", getpid(), ff, new); debug_show_fds();
// did we exec an ELF file or something?
if (!TT.LINENO++ && name && new) {
wchar_t wc;