diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 93ab86426..1313dd5d9 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1254,7 +1254,7 @@ line_input_t* FAST_FUNC new_line_input_t(int flags) | |||
1254 | 1254 | ||
1255 | #if MAX_HISTORY > 0 | 1255 | #if MAX_HISTORY > 0 |
1256 | 1256 | ||
1257 | unsigned size_from_HISTFILESIZE(const char *hp) | 1257 | unsigned FAST_FUNC size_from_HISTFILESIZE(const char *hp) |
1258 | { | 1258 | { |
1259 | int size = MAX_HISTORY; | 1259 | int size = MAX_HISTORY; |
1260 | if (hp) { | 1260 | if (hp) { |
@@ -1309,6 +1309,17 @@ static int get_next_history(void) | |||
1309 | return 0; | 1309 | return 0; |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | /* Lists command history. Used by shell 'history' builtins */ | ||
1313 | void FAST_FUNC show_history(const line_input_t *st) | ||
1314 | { | ||
1315 | int i; | ||
1316 | |||
1317 | if (!st) | ||
1318 | return; | ||
1319 | for (i = 0; i < st->cnt_history; i++) | ||
1320 | printf("%4d %s\n", i, st->history[i]); | ||
1321 | } | ||
1322 | |||
1312 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY | 1323 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY |
1313 | /* We try to ensure that concurrent additions to the history | 1324 | /* We try to ensure that concurrent additions to the history |
1314 | * do not overwrite each other. | 1325 | * do not overwrite each other. |
@@ -2749,8 +2760,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2749 | free(command_ps); | 2760 | free(command_ps); |
2750 | #endif | 2761 | #endif |
2751 | 2762 | ||
2752 | if (command_len > 0) | 2763 | if (command_len > 0) { |
2753 | remember_in_history(command); | 2764 | remember_in_history(command); |
2765 | } | ||
2754 | 2766 | ||
2755 | if (break_out > 0) { | 2767 | if (break_out > 0) { |
2756 | command[command_len++] = '\n'; | 2768 | command[command_len++] = '\n'; |