diff --git a/include/editline.h b/include/editline.h index a401531..892cca3 100644 --- a/include/editline.h +++ b/include/editline.h @@ -72,7 +72,8 @@ extern char *rl_line_buffer; extern const char *rl_readline_name; extern FILE *rl_instream; /* The stdio stream from which input is read. Defaults to stdin if NULL - Not supported yet! */ extern FILE *rl_outstream; /* The stdio stream to which output is flushed. Defaults to stdout if NULL - Not supported yet! */ -extern int el_no_echo; /* e.g under emacs, don't echo except prompt */ +extern int el_no_echo; /* E.g under emacs, don't echo except prompt */ +extern int el_no_hist; /* Disable auto-save of and access to history -- e.g. for password prompts or wizards */ extern int el_hist_size; /* size of history scrollback buffer, default: 15 */ extern void rl_initialize(void); diff --git a/src/editline.c b/src/editline.c index 6222532..130d79f 100644 --- a/src/editline.c +++ b/src/editline.c @@ -107,6 +107,7 @@ static int tty_cols = SCREEN_COLS; static int tty_rows = SCREEN_ROWS; int el_no_echo = 0; /* e.g., under Emacs */ +int el_no_hist = 0; int rl_point; int rl_mark; int rl_end; @@ -547,11 +548,17 @@ static el_status_t do_hist(const char *(*move)(void)) static el_status_t h_next(void) { + if (el_no_hist) + return CSstay; + return do_hist(next_hist); } static el_status_t h_prev(void) { + if (el_no_hist) + return CSstay; + return do_hist(prev_hist); } @@ -1210,8 +1217,8 @@ char *readline(const char *prompt) free(Screen); free(H.Lines[--H.Size]); - /* Add to history, unless no-echo mode ... */ - if (!el_no_echo) { + /* Add to history, unless no-echo or no-history mode ... */ + if (!el_no_echo && !el_no_hist) { if (line != NULL && *line != '\0') hist_add(line); }