From 3aaf63f6d908eea164111791ec90fd608000dfe1 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 19 Mar 2021 03:52:09 -0500 Subject: Fix another sh regression. --- toys/pending/sh.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'toys/pending') diff --git a/toys/pending/sh.c b/toys/pending/sh.c index b3414a7e..f5ed9bd4 100644 --- a/toys/pending/sh.c +++ b/toys/pending/sh.c @@ -646,7 +646,10 @@ static char *parse_word(char *start, int early, int quote) end++; } else toybuf[quote++] = ")}]"[qq]; } else if (*end=='(' && strchr("?*+@!", ii)) toybuf[quote++] = ')'; - else end--; + else { + end--; + if (early && !quote) return end; + } end++; } } @@ -1362,7 +1365,7 @@ static int expand_arg_nobrace(struct sh_arg *arg, char *str, unsigned flags, // both types of subshell work the same, so do $( here not in '$' below // TODO $((echo hello) | cat) ala $(( becomes $( ( retroactively - } else if (cc == '`' || (cc == '$' && strchr("([", str[ii]))) { + } else if (cc == '`' || (cc == '$' && str[ii] && strchr("([", str[ii]))) { off_t pp = 0; s = str+ii-1; -- cgit v1.2.3