From f5018dac21df54647d0982ed4bebd0286d77cc56 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Apr 2018 17:58:21 +0200 Subject: hush: fix "unset PS1/PS2", and put them into initial variable set "unset PS1/PS2" causes prompts to be empty strings function old new delta hush_main 1031 1089 +58 goto_new_line 27 33 +6 fgetc_interactive 244 245 +1 unset_local_var 155 149 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 65/-6) Total: 59 bytes Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libbb/lineedit.c') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 678c4d29c..d5e92e84c 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -430,7 +430,8 @@ static void put_till_end_and_adv_cursor(void) static void goto_new_line(void) { put_till_end_and_adv_cursor(); - if (cmdedit_x != 0) + /* "cursor == 0" is only if prompt is "" and user input is empty */ + if (cursor == 0 || cmdedit_x != 0) bb_putchar('\n'); } -- cgit v1.2.3