I've been using bash's edit-and-execute-command
function:
edit-and-execute-command (C-x C-e)
Invoke an editor on the current command line, and execute the result as shell commands. Bash attempts to invoke
$VISUAL
,$EDITOR
, andemacs
as the editor, in that order.
https://www.gnu.org/software/bash/manual/html_node/Miscellaneous-Commands.html
I've noticed that if I invoke an editor,
use Ctrl-Z to put it into the background,
and then use fg
to put it back into the foreground,
the shell no longer executes the temporary file.
This is handy if I want to abort the command, but I found the behavior a little surprising the first time it happened.
My questions:
Why does this happen?
I know from the source code that
edit_and_execute_command
eventually callsfc
, but it's not immediately clear to me why sending SIGTSTP prevents bash from executing the temporary file.If I had accidentally hit Ctrl-Z and still wanted to execute the script in the temporary file still open by the editor, what would be the best way of doing that?