diff options
Diffstat (limited to 'shell/msh.c')
-rw-r--r-- | shell/msh.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/shell/msh.c b/shell/msh.c index c88308f8f..8746e42bc 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <setjmp.h> | 17 | #include <setjmp.h> |
18 | #include <sys/times.h> | 18 | #include <sys/times.h> |
19 | 19 | ||
20 | #include "cmdedit.h" | ||
21 | 20 | ||
22 | /*#define MSHDEBUG 1*/ | 21 | /*#define MSHDEBUG 1*/ |
23 | 22 | ||
@@ -777,7 +776,7 @@ void print_tree(struct op *head) | |||
777 | #endif /* MSHDEBUG */ | 776 | #endif /* MSHDEBUG */ |
778 | 777 | ||
779 | 778 | ||
780 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 779 | #if ENABLE_FEATURE_COMMAND_EDITING |
781 | static char *current_prompt; | 780 | static char *current_prompt; |
782 | #endif | 781 | #endif |
783 | 782 | ||
@@ -787,6 +786,10 @@ static char *current_prompt; | |||
787 | */ | 786 | */ |
788 | 787 | ||
789 | 788 | ||
789 | #if ENABLE_FEATURE_COMMAND_EDITING | ||
790 | static line_input_t *line_input_state; | ||
791 | #endif | ||
792 | |||
790 | int msh_main(int argc, char **argv) | 793 | int msh_main(int argc, char **argv) |
791 | { | 794 | { |
792 | int f; | 795 | int f; |
@@ -795,6 +798,10 @@ int msh_main(int argc, char **argv) | |||
795 | char *name, **ap; | 798 | char *name, **ap; |
796 | int (*iof) (struct ioarg *); | 799 | int (*iof) (struct ioarg *); |
797 | 800 | ||
801 | #if ENABLE_FEATURE_COMMAND_EDITING | ||
802 | line_input_state = new_line_input_t(FOR_SHELL); | ||
803 | #endif | ||
804 | |||
798 | DBGPRINTF(("MSH_MAIN: argc %d, environ %p\n", argc, environ)); | 805 | DBGPRINTF(("MSH_MAIN: argc %d, environ %p\n", argc, environ)); |
799 | 806 | ||
800 | initarea(); | 807 | initarea(); |
@@ -964,7 +971,7 @@ int msh_main(int argc, char **argv) | |||
964 | 971 | ||
965 | for (;;) { | 972 | for (;;) { |
966 | if (interactive && e.iop <= iostack) { | 973 | if (interactive && e.iop <= iostack) { |
967 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 974 | #if ENABLE_FEATURE_COMMAND_EDITING |
968 | current_prompt = prompt->value; | 975 | current_prompt = prompt->value; |
969 | #else | 976 | #else |
970 | prs(prompt->value); | 977 | prs(prompt->value); |
@@ -2371,7 +2378,7 @@ static int yylex(int cf) | |||
2371 | startl = 1; | 2378 | startl = 1; |
2372 | if (multiline || cf & CONTIN) { | 2379 | if (multiline || cf & CONTIN) { |
2373 | if (interactive && e.iop <= iostack) { | 2380 | if (interactive && e.iop <= iostack) { |
2374 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 2381 | #if ENABLE_FEATURE_COMMAND_EDITING |
2375 | current_prompt = cprompt->value; | 2382 | current_prompt = cprompt->value; |
2376 | #else | 2383 | #else |
2377 | prs(cprompt->value); | 2384 | prs(cprompt->value); |
@@ -2432,7 +2439,7 @@ static int collect(int c, int c1) | |||
2432 | return YYERRCODE; | 2439 | return YYERRCODE; |
2433 | } | 2440 | } |
2434 | if (interactive && c == '\n' && e.iop <= iostack) { | 2441 | if (interactive && c == '\n' && e.iop <= iostack) { |
2435 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 2442 | #if ENABLE_FEATURE_COMMAND_EDITING |
2436 | current_prompt = cprompt->value; | 2443 | current_prompt = cprompt->value; |
2437 | #else | 2444 | #else |
2438 | prs(cprompt->value); | 2445 | prs(cprompt->value); |
@@ -4666,7 +4673,7 @@ static int readc(void) | |||
4666 | return e.iop->prev = 0; | 4673 | return e.iop->prev = 0; |
4667 | } | 4674 | } |
4668 | if (interactive && e.iop == iostack + 1) { | 4675 | if (interactive && e.iop == iostack + 1) { |
4669 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 4676 | #if ENABLE_FEATURE_COMMAND_EDITING |
4670 | current_prompt = prompt->value; | 4677 | current_prompt = prompt->value; |
4671 | #else | 4678 | #else |
4672 | prs(prompt->value); | 4679 | prs(prompt->value); |
@@ -4898,13 +4905,13 @@ static int filechar(struct ioarg *ap) | |||
4898 | ap->afpos++; | 4905 | ap->afpos++; |
4899 | return *bp->bufp++ & 0177; | 4906 | return *bp->bufp++ & 0177; |
4900 | } | 4907 | } |
4901 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 4908 | #if ENABLE_FEATURE_COMMAND_EDITING |
4902 | if (interactive && isatty(ap->afile)) { | 4909 | if (interactive && isatty(ap->afile)) { |
4903 | static char mycommand[BUFSIZ]; | 4910 | static char mycommand[BUFSIZ]; |
4904 | static int position = 0, size = 0; | 4911 | static int position = 0, size = 0; |
4905 | 4912 | ||
4906 | while (size == 0 || position >= size) { | 4913 | while (size == 0 || position >= size) { |
4907 | cmdedit_read_input(current_prompt, mycommand); | 4914 | read_line_input(current_prompt, mycommand, BUFSIZ, line_input_state); |
4908 | size = strlen(mycommand); | 4915 | size = strlen(mycommand); |
4909 | position = 0; | 4916 | position = 0; |
4910 | } | 4917 | } |
@@ -4913,7 +4920,6 @@ static int filechar(struct ioarg *ap) | |||
4913 | return c; | 4920 | return c; |
4914 | } else | 4921 | } else |
4915 | #endif | 4922 | #endif |
4916 | |||
4917 | { | 4923 | { |
4918 | i = safe_read(ap->afile, &c, sizeof(c)); | 4924 | i = safe_read(ap->afile, &c, sizeof(c)); |
4919 | return i == sizeof(c) ? (c & 0x7f) : (closef(ap->afile), 0); | 4925 | return i == sizeof(c) ? (c & 0x7f) : (closef(ap->afile), 0); |
@@ -5150,7 +5156,7 @@ static void readhere(char **name, char *s, int ec) | |||
5150 | e.iobase = e.iop; | 5156 | e.iobase = e.iop; |
5151 | for (;;) { | 5157 | for (;;) { |
5152 | if (interactive && e.iop <= iostack) { | 5158 | if (interactive && e.iop <= iostack) { |
5153 | #ifdef CONFIG_FEATURE_COMMAND_EDITING | 5159 | #if ENABLE_FEATURE_COMMAND_EDITING |
5154 | current_prompt = cprompt->value; | 5160 | current_prompt = cprompt->value; |
5155 | #else | 5161 | #else |
5156 | prs(cprompt->value); | 5162 | prs(cprompt->value); |