edit-and-execute-command interrupted by SIGTSTP
3
votes
2
answers
611
views
I've been using bash's [
edit-and-execute-command
function](https://git.savannah.gnu.org/cgit/bash.git/tree/bashline.c?id=3ba697465bc74fab513a26dea700cc82e9f4724e#n935) :
> **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
, and emacs
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 calls fc
](https://git.savannah.gnu.org/cgit/bash.git/tree/bashline.c?id=3ba697465bc74fab513a26dea700cc82e9f4724e#n957) ,
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?
Asked by Nathaniel M. Beaver
(1398 rep)
Jul 3, 2019, 10:56 PM
Last activity: Jan 24, 2020, 11:43 AM
Last activity: Jan 24, 2020, 11:43 AM