summaryrefslogtreecommitdiff
path: root/shell/msh.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-01-22 07:21:38 +0000
committerDenis Vlasenko2007-01-22 07:21:38 +0000
commit8e1c71529c2bf38a04d4a117e625e59044a0785a (patch)
tree2f115293c25e7ee9307f268ec198e2cf486ff070 /shell/msh.c
parent00cdbd8fc20a4e2e2208f90a2691a3806c931b06 (diff)
downloadbusybox-8e1c71529c2bf38a04d4a117e625e59044a0785a.zip
busybox-8e1c71529c2bf38a04d4a117e625e59044a0785a.tar.gz
Convert cmdedit into more generic line input facility
(make history and completion optional at runtime). Use it for fdisk, as an example. Some unrelated fixes in fdisk are also here.
Diffstat (limited to 'shell/msh.c')
-rw-r--r--shell/msh.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/shell/msh.c b/shell/msh.c
index c88308f..8746e42 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -17,7 +17,6 @@
#include <setjmp.h>
#include <sys/times.h>
-#include "cmdedit.h"
/*#define MSHDEBUG 1*/
@@ -777,7 +776,7 @@ void print_tree(struct op *head)
#endif /* MSHDEBUG */
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
+#if ENABLE_FEATURE_COMMAND_EDITING
static char *current_prompt;
#endif
@@ -787,6 +786,10 @@ static char *current_prompt;
*/
+#if ENABLE_FEATURE_COMMAND_EDITING
+static line_input_t *line_input_state;
+#endif
+
int msh_main(int argc, char **argv)
{
int f;
@@ -795,6 +798,10 @@ int msh_main(int argc, char **argv)
char *name, **ap;
int (*iof) (struct ioarg *);
+#if ENABLE_FEATURE_COMMAND_EDITING
+ line_input_state = new_line_input_t(FOR_SHELL);
+#endif
+
DBGPRINTF(("MSH_MAIN: argc %d, environ %p\n", argc, environ));
initarea();
@@ -964,7 +971,7 @@ int msh_main(int argc, char **argv)
for (;;) {
if (interactive && e.iop <= iostack) {
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
+#if ENABLE_FEATURE_COMMAND_EDITING
current_prompt = prompt->value;
#else
prs(prompt->value);
@@ -2371,7 +2378,7 @@ static int yylex(int cf)
startl = 1;
if (multiline || cf & CONTIN) {
if (interactive && e.iop <= iostack) {
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
+#if ENABLE_FEATURE_COMMAND_EDITING
current_prompt = cprompt->value;
#else
prs(cprompt->value);
@@ -2432,7 +2439,7 @@ static int collect(int c, int c1)
return YYERRCODE;
}
if (interactive && c == '\n' && e.iop <= iostack) {
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
+#if ENABLE_FEATURE_COMMAND_EDITING
current_prompt = cprompt->value;
#else
prs(cprompt->value);
@@ -4666,7 +4673,7 @@ static int readc(void)
return e.iop->prev = 0;
}
if (interactive && e.iop == iostack + 1) {
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
+#if ENABLE_FEATURE_COMMAND_EDITING
current_prompt = prompt->value;
#else
prs(prompt->value);
@@ -4898,13 +4905,13 @@ static int filechar(struct ioarg *ap)
ap->afpos++;
return *bp->bufp++ & 0177;
}
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
+#if ENABLE_FEATURE_COMMAND_EDITING
if (interactive && isatty(ap->afile)) {
static char mycommand[BUFSIZ];
static int position = 0, size = 0;
while (size == 0 || position >= size) {
- cmdedit_read_input(current_prompt, mycommand);
+ read_line_input(current_prompt, mycommand, BUFSIZ, line_input_state);
size = strlen(mycommand);
position = 0;
}
@@ -4913,7 +4920,6 @@ static int filechar(struct ioarg *ap)
return c;
} else
#endif
-
{
i = safe_read(ap->afile, &c, sizeof(c));
return i == sizeof(c) ? (c & 0x7f) : (closef(ap->afile), 0);
@@ -5150,7 +5156,7 @@ static void readhere(char **name, char *s, int ec)
e.iobase = e.iop;
for (;;) {
if (interactive && e.iop <= iostack) {
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
+#if ENABLE_FEATURE_COMMAND_EDITING
current_prompt = cprompt->value;
#else
prs(cprompt->value);