summaryrefslogtreecommitdiffstats
path: root/common/hush.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-02-21 15:15:23 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-02-26 11:05:02 +0100
commit6ad2bdb8e19f6ccc53b715351435e62b800021b9 (patch)
tree1aba4de942f844cbc5e88d3c94c12647253bfc3c /common/hush.c
parent4cb9d4fa0ea4e3a2d46a8c6ebc38341ff0a8afde (diff)
downloadbarebox-6ad2bdb8e19f6ccc53b715351435e62b800021b9.tar.gz
barebox-6ad2bdb8e19f6ccc53b715351435e62b800021b9.tar.xz
hush: implement $*
To get all arguments a script is called with. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/hush.c')
-rw-r--r--common/hush.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/hush.c b/common/hush.c
index 602f8f1be1..b5e111a019 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -335,6 +335,19 @@ static int b_addchr(o_string *o, int ch)
return 0;
}
+static int b_addstr(o_string *o, const char *str)
+{
+ int ret;
+
+ while (*str) {
+ ret = b_addchr(o, *str++);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static void b_reset(o_string *o)
{
o->length = 0;
@@ -1407,6 +1420,14 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
}
b_addchr(dest, SPECIAL_VAR_SYMBOL);
break;
+ case '*':
+ for (i = 1; i < ctx->global_argc; i++) {
+ b_addstr(dest, ctx->global_argv[i]);
+ b_addchr(dest, ' ');
+ }
+
+ advance = 1;
+ break;
default:
b_addchr(dest, '$');
}