aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-01-29 19:47:31 -0600
committerRob Landley <rob@landley.net>2020-01-29 19:47:31 -0600
commitde6b75b187e92318b57865e2c404d2351474ddc1 (patch)
tree3e10e530b360eec6806248904c5333b5605e1bea
parent70ab2dfb923e98fc1b0af27ec98efd0220fe6de6 (diff)
downloadtoybox-de6b75b187e92318b57865e2c404d2351474ddc1.tar.gz
Quick and dirty "echo $ABC" support, done totally the wrong way, but it
makes those two remaining tests pass.
-rw-r--r--toys/pending/sh.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 98f5a17e..bba410aa 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -217,8 +217,6 @@ static char *getvar(char *s)
return getvarlen(s, strlen(s));
}
-
-
// returns pointer to next unquoted (or double quoted if dquot) char.
// handle \ '' "" `` $()
int skip_quote(char *s, int dquot, int *depth)
@@ -304,6 +302,15 @@ static void expand_arg_nobrace(struct sh_arg *arg, char *old, unsigned flags,
// ${ $(( $( $[ $' ` " '
+// TODO this is wrong
+ if (*new == '$') {
+ char *s = getvar(new+1);
+
+ if (new != old) free(new);
+ if (!s) return;
+ new = xstrdup(s);
+ }
+
/*
while (*s) {
if (!quote && !(flags&NO_BRACE) && *s == '{') {
@@ -333,8 +340,9 @@ TODO this recurses
}
*/
+// TODO not else?
// quote removal
- if (!(flags&NO_QUOTE)) {
+ else if (!(flags&NO_QUOTE)) {
int to = 0, from = 0;
for (;;) {
@@ -915,7 +923,7 @@ if (BUGBUG) { int i; dprintf(255, "envlen=%d arg->c=%d run=", envlen, arg->c); f
env[ll] = sss;
break;
}
- if (ll == kk) array_add(&env, kk, sss);
+ if (ll == kk) array_add(&env, kk++, sss);
}
environ = env;
}