diff options
author | Rob Landley <rob@landley.net> | 2020-10-14 23:40:10 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-10-14 23:40:10 -0500 |
commit | 8eb9d6e0d3217bd0b1ffba73b3dfda1f79787845 (patch) | |
tree | 79ac910e0ef66b76d7c0649d96b98ec3216c6c71 /toys/pending | |
parent | 0612ad28343073b9d6fc13b4640967cf0351f958 (diff) | |
download | toybox-8eb9d6e0d3217bd0b1ffba73b3dfda1f79787845.tar.gz |
Fix && || traversing loops, and typecast past size_t being stupidly typed.
Diffstat (limited to 'toys/pending')
-rw-r--r-- | toys/pending/sh.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c index 6a98a787..b6528a96 100644 --- a/toys/pending/sh.c +++ b/toys/pending/sh.c @@ -1253,7 +1253,7 @@ dprintf(2, "TODO: do math for %.*s\n", kk, s); else if (cc == '#') { // TODO ${#x[@]} dd = !!strchr("@*", *ss); // For ${#@} or ${#*} do normal ${#} ifs = getvar_special(ss-dd, jj, &kk, delete) ? : ""; - if (!dd) push_arg(delete, ifs = xmprintf("%ld", strlen(ifs))); + if (!dd) push_arg(delete, ifs = xmprintf("%ld", (long)strlen(ifs))); // ${!@} ${!@Q} ${!x} ${!x@} ${!x@Q} ${!x#} ${!x[} ${!x[*]} } else if (cc == '!') { // TODO: ${var[@]} array @@ -2961,10 +2961,12 @@ dprintf(2, "TODO skipped running for((;;)), need math parser\n"); } // for && and || skip pipeline segment(s) based on return code - if (!pl->type || pl->type == 3) - while (ctl && !strcmp(ctl, toys.exitval ? "&&" : "||")) - ctl = (pl = pl->type ? pl->end : pl->next) ? pl->arg->v[pl->arg->c] : 0; - + if (!pl->type || pl->type == 3) { + while (ctl && !strcmp(ctl, toys.exitval ? "&&" : "||")) { + if ((pl = pl->next)->type) pl = pl->end; + ctl = pl->arg->v[pl->arg->c]; + } + } pl = pl->next; } |