[PATCH 2/2] hush: implement $*
Sascha Hauer
s.hauer at pengutronix.de
Thu Feb 21 09:17:14 EST 2013
To get all arguments a script is called with.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/hush.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/common/hush.c b/common/hush.c
index 5927ad6..43ce3ba 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;
@@ -1410,6 +1423,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, '$');
}
--
1.7.10.4
More information about the barebox
mailing list