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/lash.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/lash.c')
-rw-r--r-- | shell/lash.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/shell/lash.c b/shell/lash.c index b2ccaf0a1..a09a9a9b1 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | #include "busybox.h" | 24 | #include "busybox.h" |
25 | #include <getopt.h> | 25 | #include <getopt.h> |
26 | #include "cmdedit.h" | ||
27 | |||
28 | #include <glob.h> | 26 | #include <glob.h> |
29 | #define expand_t glob_t | 27 | #define expand_t glob_t |
30 | 28 | ||
@@ -641,6 +639,10 @@ static inline void setup_prompt_string(char **prompt_str) | |||
641 | #endif | 639 | #endif |
642 | } | 640 | } |
643 | 641 | ||
642 | #if ENABLE_FEATURE_COMMAND_EDITING | ||
643 | static line_input_t *line_input_state; | ||
644 | #endif | ||
645 | |||
644 | static int get_command(FILE * source, char *command) | 646 | static int get_command(FILE * source, char *command) |
645 | { | 647 | { |
646 | char *prompt_str; | 648 | char *prompt_str; |
@@ -659,14 +661,14 @@ static int get_command(FILE * source, char *command) | |||
659 | if (source == stdin) { | 661 | if (source == stdin) { |
660 | setup_prompt_string(&prompt_str); | 662 | setup_prompt_string(&prompt_str); |
661 | 663 | ||
662 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 664 | #if ENABLE_FEATURE_COMMAND_EDITING |
663 | /* | 665 | /* |
664 | ** enable command line editing only while a command line | 666 | ** enable command line editing only while a command line |
665 | ** is actually being read; otherwise, we'll end up bequeathing | 667 | ** is actually being read; otherwise, we'll end up bequeathing |
666 | ** atexit() handlers and other unwanted stuff to our | 668 | ** atexit() handlers and other unwanted stuff to our |
667 | ** child processes (rob@sysgo.de) | 669 | ** child processes (rob@sysgo.de) |
668 | */ | 670 | */ |
669 | cmdedit_read_input(prompt_str, command); | 671 | read_line_input(prompt_str, command, BUFSIZ, line_input_state); |
670 | return 0; | 672 | return 0; |
671 | #else | 673 | #else |
672 | fputs(prompt_str, stdout); | 674 | fputs(prompt_str, stdout); |
@@ -1505,6 +1507,10 @@ int lash_main(int argc_l, char **argv_l) | |||
1505 | argc = argc_l; | 1507 | argc = argc_l; |
1506 | argv = argv_l; | 1508 | argv = argv_l; |
1507 | 1509 | ||
1510 | #if ENABLE_FEATURE_COMMAND_EDITING | ||
1511 | line_input_state = new_line_input_t(FOR_SHELL); | ||
1512 | #endif | ||
1513 | |||
1508 | /* These variables need re-initializing when recursing */ | 1514 | /* These variables need re-initializing when recursing */ |
1509 | last_jobid = 0; | 1515 | last_jobid = 0; |
1510 | close_me_list = NULL; | 1516 | close_me_list = NULL; |