mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] hush: implement $*
Date: Thu, 21 Feb 2013 15:17:14 +0100	[thread overview]
Message-ID: <1361456235-30969-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1361456235-30969-1-git-send-email-s.hauer@pengutronix.de>

To get all arguments a script is called with.

Signed-off-by: Sascha Hauer <s.hauer@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-02-21 14:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21 14:17 [PATCH 1/2] hush: expand variables before globbing in for loops Sascha Hauer
2013-02-21 14:17 ` Sascha Hauer [this message]
2013-02-22  8:13 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361456235-30969-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox