From 145366b9719857c48f9a7ada7d7e0ff8edfbd0de Mon Sep 17 00:00:00 2001 From: vda Date: Mon, 22 Jan 2007 07:21:38 +0000 Subject: 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. git-svn-id: svn://busybox.net/trunk/busybox@17446 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- shell/hush.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'shell/hush.c') diff --git a/shell/hush.c b/shell/hush.c index 8f2dc80f2..2c88238ae 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -98,7 +98,6 @@ /* #include */ /* #define DEBUG_SHELL */ -#include "cmdedit.h" #define SPECIAL_VAR_SYMBOL 03 #define FLAG_EXIT_FROM_LOOP 1 @@ -883,20 +882,24 @@ static void setup_prompt_string(int promptmode, char **prompt_str) debug_printf("result %s\n",*prompt_str); } +#if ENABLE_FEATURE_COMMAND_EDITING +static line_input_t *line_input_state; +#endif + static void get_user_input(struct in_str *i) { char *prompt_str; static char the_command[BUFSIZ]; setup_prompt_string(i->promptmode, &prompt_str); -#ifdef CONFIG_FEATURE_COMMAND_EDITING +#if ENABLE_FEATURE_COMMAND_EDITING /* ** enable command line editing only while a command line ** is actually being read; otherwise, we'll end up bequeathing ** atexit() handlers and other unwanted stuff to our ** child processes (rob@sysgo.de) */ - cmdedit_read_input(prompt_str, the_command); + read_line_input(prompt_str, the_command, BUFSIZ, line_input_state); #else fputs(prompt_str, stdout); fflush(stdout); @@ -2647,6 +2650,10 @@ int hush_main(int argc, char **argv) FILE *input; char **e = environ; +#ifdef CONFIG_FEATURE_COMMAND_EDITING + line_input_state = new_line_input_t(FOR_SHELL); +#endif + /* XXX what should these be while sourcing /etc/profile? */ global_argc = argc; global_argv = argv; -- cgit v1.2.3-55-g6feb