9
0
Fork 0

hush: implement $*

To get all arguments a script is called with.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-02-21 15:15:23 +01:00
parent 4cb9d4fa0e
commit 6ad2bdb8e1
1 changed files with 21 additions and 0 deletions

View File

@ -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, '$');
}