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>
master
Benno Schulenberg 2017-10-28 12:27:04 +02:00
parent 42497f77e2
commit 84c650b80a
1 changed files with 6 additions and 3 deletions

View File

@ -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. */