diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-19 18:24:52 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-19 18:24:52 +0200 |
| commit | 76a4e8361a84efca256d4286cf36561c42c14d64 (patch) | |
| tree | 9c3b9f82e5d86a08d646d554d3d3800bd1404d79 /shell | |
| parent | 9edd268bad93128bcadfbdde28bb978a4b4c5bab (diff) | |
| download | busybox-w32-76a4e8361a84efca256d4286cf36561c42c14d64.tar.gz busybox-w32-76a4e8361a84efca256d4286cf36561c42c14d64.tar.bz2 busybox-w32-76a4e8361a84efca256d4286cf36561c42c14d64.zip | |
hush: allocate line edit buffer only for interactive shell
function old new delta
builtin_history 16 20 +4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/hush.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/shell/hush.c b/shell/hush.c index 9dd893aa6..4dd940222 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -2032,7 +2032,8 @@ static sighandler_t pick_sighandler(unsigned sig) | |||
| 2032 | static void hush_exit(int exitcode) | 2032 | static void hush_exit(int exitcode) |
| 2033 | { | 2033 | { |
| 2034 | #if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT | 2034 | #if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT |
| 2035 | save_history(G.line_input_state); | 2035 | if (G.line_input_state) |
| 2036 | save_history(G.line_input_state); | ||
| 2036 | #endif | 2037 | #endif |
| 2037 | 2038 | ||
| 2038 | fflush_all(); | 2039 | fflush_all(); |
| @@ -6412,6 +6413,8 @@ static NOINLINE int expand_one_var(o_string *output, int n, | |||
| 6412 | * commands read but are not executed, | 6413 | * commands read but are not executed, |
| 6413 | * so $- can not execute too, 'n' is never seen in $-. | 6414 | * so $- can not execute too, 'n' is never seen in $-. |
| 6414 | */ | 6415 | */ |
| 6416 | //TODO: show 'c' if executed via "hush -c 'CMDS'" (bash only, not ash) | ||
| 6417 | //TODO: show 's' if executed via "hush -s ARG1 ARG2", or if there were no args except options (ash does this too) | ||
| 6415 | *cp = '\0'; | 6418 | *cp = '\0'; |
| 6416 | break; | 6419 | break; |
| 6417 | } | 6420 | } |
| @@ -9955,9 +9958,6 @@ int hush_main(int argc, char **argv) | |||
| 9955 | * PS4='+ ' | 9958 | * PS4='+ ' |
| 9956 | */ | 9959 | */ |
| 9957 | 9960 | ||
| 9958 | #if ENABLE_FEATURE_EDITING | ||
| 9959 | G.line_input_state = new_line_input_t(FOR_SHELL); | ||
| 9960 | #endif | ||
| 9961 | 9961 | ||
| 9962 | /* Initialize some more globals to non-zero values */ | 9962 | /* Initialize some more globals to non-zero values */ |
| 9963 | die_func = restore_ttypgrp_and__exit; | 9963 | die_func = restore_ttypgrp_and__exit; |
| @@ -10245,6 +10245,9 @@ int hush_main(int argc, char **argv) | |||
| 10245 | } | 10245 | } |
| 10246 | enable_restore_tty_pgrp_on_exit(); | 10246 | enable_restore_tty_pgrp_on_exit(); |
| 10247 | 10247 | ||
| 10248 | # if ENABLE_FEATURE_EDITING | ||
| 10249 | G.line_input_state = new_line_input_t(FOR_SHELL); | ||
| 10250 | # endif | ||
| 10248 | # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 | 10251 | # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 |
| 10249 | { | 10252 | { |
| 10250 | const char *hp = get_local_var_value("HISTFILE"); | 10253 | const char *hp = get_local_var_value("HISTFILE"); |
| @@ -10372,7 +10375,8 @@ static int FAST_FUNC builtin_help(char **argv UNUSED_PARAM) | |||
| 10372 | #if MAX_HISTORY && ENABLE_FEATURE_EDITING | 10375 | #if MAX_HISTORY && ENABLE_FEATURE_EDITING |
| 10373 | static int FAST_FUNC builtin_history(char **argv UNUSED_PARAM) | 10376 | static int FAST_FUNC builtin_history(char **argv UNUSED_PARAM) |
| 10374 | { | 10377 | { |
| 10375 | show_history(G.line_input_state); | 10378 | if (G.line_input_state) |
| 10379 | show_history(G.line_input_state); | ||
| 10376 | return EXIT_SUCCESS; | 10380 | return EXIT_SUCCESS; |
| 10377 | } | 10381 | } |
| 10378 | #endif | 10382 | #endif |
