From 6ad2bdb8e19f6ccc53b715351435e62b800021b9 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 21 Feb 2013 15:15:23 +0100 Subject: hush: implement $* To get all arguments a script is called with. Signed-off-by: Sascha Hauer --- common/hush.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'common/hush.c') 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, '$'); } -- cgit v1.2.3