mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/1] menu: export box state to menu_box_state when using a command
Date: Sun, 27 May 2012 12:36:32 +0200	[thread overview]
Message-ID: <1338114992-13130-1-git-send-email-plagnioj@jcrosoft.com> (raw)

this will allow to have different action based on the box state in shell

as example
menu -e -a -m boot -c 'export test=${menu_box_state}' -R -b 1 -d "yes/no"

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/menu.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/common/menu.c b/common/menu.c
index 6c530b6..070170e 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -483,6 +483,11 @@ static void menu_action_command(struct menu *m, struct menu_entry *me)
 	int ret;
 	const char *s = getenv(e->command);
 
+	if (me->type == MENU_ENTRY_BOX)
+		export_env_ull("menu_box_state", me->box_state);
+	else
+		setenv("menu_box_state", "");
+
 	/* can be a command as boot */
 	if (!s)
 		s = e->command;
-- 
1.7.9.1


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

             reply	other threads:[~2012-05-27 10:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27 10:36 Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-06-01  6:33 ` 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=1338114992-13130-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --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