Do not add silent mode history items to history

Prior to this fix, if you invoked fish with --private and then used
`read --silent` to read something sensitive, the variable would be
stored in history, with the plain text available through up-arrow.
Fix it to not store items in silent mode.

Note the item was never written to disk; it was only stored in memory.

Fixes #7230
This commit is contained in:
ridiculousfish 2020-07-30 20:22:54 -07:00
parent caf64fd0ce
commit 81d5a3ea64

View file

@ -3018,9 +3018,9 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
if (command_test_result == 0) {
// Finished command, execute it. Don't add items that start with a leading
// space.
// space, or if in silent mode (#7230).
const editable_line_t *el = &command_line;
if (history != nullptr && may_add_to_history(el->text())) {
if (history != nullptr && !silent && may_add_to_history(el->text())) {
history->add_pending_with_file_detection(el->text(), vars.get_pwd_slash());
}
rls.finished = true;