summaryrefslogtreecommitdiffstats
path: root/common/parser.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-09-24 01:40:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2007-09-24 01:40:06 +0200
commit14b5c2a647924440444977806c72b8ee6f586e26 (patch)
tree66dbf1b77d7ed2222db20a7a13ac9a7461d16a69 /common/parser.c
parentd97304aef21a7f3ac5a6699e3549e30507c760a3 (diff)
downloadbarebox-14b5c2a647924440444977806c72b8ee6f586e26.tar.gz
barebox-14b5c2a647924440444977806c72b8ee6f586e26.tar.xz
- teach hush to honour PATH variable
- remove common/main.c. This is now handled in the different shells.
Diffstat (limited to 'common/parser.c')
-rw-r--r--common/parser.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/common/parser.c b/common/parser.c
index 5e6bf3cde2..d5308d90d9 100644
--- a/common/parser.c
+++ b/common/parser.c
@@ -289,4 +289,33 @@ int run_command (const char *cmd, int flag)
return rc;
}
-/****************************************************************************/
+static char console_buffer[CONFIG_CBSIZE]; /* console I/O buffer */
+
+int run_shell(void)
+{
+ static char lastcommand[CONFIG_CBSIZE] = { 0, };
+ int len;
+ int rc = 1;
+ int flag;
+ for (;;) {
+ len = readline (CONFIG_PROMPT, console_buffer, CONFIG_CBSIZE);
+
+ flag = 0; /* assume no special flags for now */
+ if (len > 0)
+ strcpy (lastcommand, console_buffer);
+ else if (len == 0)
+ flag |= CMD_FLAG_REPEAT;
+
+ if (len == -1)
+ puts ("<INTERRUPT>\n");
+ else
+ rc = run_command (lastcommand, flag);
+
+ if (rc <= 0) {
+ /* invalid command or not repeatable, forget it */
+ lastcommand[0] = 0;
+ }
+ }
+ return 0;
+}
+