diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-22 07:21:38 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-22 07:21:38 +0000 |
commit | 145366b9719857c48f9a7ada7d7e0ff8edfbd0de (patch) | |
tree | 2f115293c25e7ee9307f268ec198e2cf486ff070 /shell/hush.c | |
parent | 5c7a4f79ea56b11e0e9927dc51268d7049aadf2e (diff) | |
download | busybox-w32-145366b9719857c48f9a7ada7d7e0ff8edfbd0de.tar.gz busybox-w32-145366b9719857c48f9a7ada7d7e0ff8edfbd0de.tar.bz2 busybox-w32-145366b9719857c48f9a7ada7d7e0ff8edfbd0de.zip |
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
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 13 |
1 files changed, 10 insertions, 3 deletions
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 @@ | |||
98 | /* #include <dmalloc.h> */ | 98 | /* #include <dmalloc.h> */ |
99 | /* #define DEBUG_SHELL */ | 99 | /* #define DEBUG_SHELL */ |
100 | 100 | ||
101 | #include "cmdedit.h" | ||
102 | 101 | ||
103 | #define SPECIAL_VAR_SYMBOL 03 | 102 | #define SPECIAL_VAR_SYMBOL 03 |
104 | #define FLAG_EXIT_FROM_LOOP 1 | 103 | #define FLAG_EXIT_FROM_LOOP 1 |
@@ -883,20 +882,24 @@ static void setup_prompt_string(int promptmode, char **prompt_str) | |||
883 | debug_printf("result %s\n",*prompt_str); | 882 | debug_printf("result %s\n",*prompt_str); |
884 | } | 883 | } |
885 | 884 | ||
885 | #if ENABLE_FEATURE_COMMAND_EDITING | ||
886 | static line_input_t *line_input_state; | ||
887 | #endif | ||
888 | |||
886 | static void get_user_input(struct in_str *i) | 889 | static void get_user_input(struct in_str *i) |
887 | { | 890 | { |
888 | char *prompt_str; | 891 | char *prompt_str; |
889 | static char the_command[BUFSIZ]; | 892 | static char the_command[BUFSIZ]; |
890 | 893 | ||
891 | setup_prompt_string(i->promptmode, &prompt_str); | 894 | setup_prompt_string(i->promptmode, &prompt_str); |
892 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 895 | #if ENABLE_FEATURE_COMMAND_EDITING |
893 | /* | 896 | /* |
894 | ** enable command line editing only while a command line | 897 | ** enable command line editing only while a command line |
895 | ** is actually being read; otherwise, we'll end up bequeathing | 898 | ** is actually being read; otherwise, we'll end up bequeathing |
896 | ** atexit() handlers and other unwanted stuff to our | 899 | ** atexit() handlers and other unwanted stuff to our |
897 | ** child processes (rob@sysgo.de) | 900 | ** child processes (rob@sysgo.de) |
898 | */ | 901 | */ |
899 | cmdedit_read_input(prompt_str, the_command); | 902 | read_line_input(prompt_str, the_command, BUFSIZ, line_input_state); |
900 | #else | 903 | #else |
901 | fputs(prompt_str, stdout); | 904 | fputs(prompt_str, stdout); |
902 | fflush(stdout); | 905 | fflush(stdout); |
@@ -2647,6 +2650,10 @@ int hush_main(int argc, char **argv) | |||
2647 | FILE *input; | 2650 | FILE *input; |
2648 | char **e = environ; | 2651 | char **e = environ; |
2649 | 2652 | ||
2653 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | ||
2654 | line_input_state = new_line_input_t(FOR_SHELL); | ||
2655 | #endif | ||
2656 | |||
2650 | /* XXX what should these be while sourcing /etc/profile? */ | 2657 | /* XXX what should these be while sourcing /etc/profile? */ |
2651 | global_argc = argc; | 2658 | global_argc = argc; |
2652 | global_argv = argv; | 2659 | global_argv = argv; |