nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 84c650b80a32047b091e768cde00b2e39ca0b203
parent 42497f77e28bb13f71b4694a2e55d252b1bfa6b8
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat, 28 Oct 2017 12:27:04 +0200

files: avoid an abortion when excuting a command in a new buffer

The key sequence ^R ^X M-F <Enter> would cause nano to abort, because
it would try to add an empty string to a history list.  (Furthermore,
simply don't execute an empty command, because it is pointless.)

Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>

Diffstat:
Msrc/files.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -1127,11 +1127,14 @@ void do_insertfile(void) if (ISSET(MULTIBUFFER)) open_buffer("", FALSE); #endif - /* Save the command's output in the current buffer. */ - execute_command(answer); + /* If the command is not empty, execute it and read its output + * into the buffer, and add the command to the history list. */ + if (*answer != '\0') { + execute_command(answer); #ifndef DISABLE_HISTORIES - update_history(&execute_history, answer); + update_history(&execute_history, answer); #endif + } #ifdef ENABLE_MULTIBUFFER /* If this is a new buffer, put the cursor at the top. */