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, and emacs as the editor, in that order.


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, 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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.