New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
read followed by ctrl+c terminates bash shell-session [bash 5.1 fixed] #627
Comments
|
It looks like a bug in bash to me. I can reproduce the same behavior by setting this in my shell: |
|
I can reproduce this both in bash 4.4.23(1) and 5.0.16(1) |
|
I have this problem as well, on Fedora. |
|
Look at the diff in the hook between the two versions I had here |
|
Removing the |
|
Okay, but this is how it was before 2.21 when #555 was merged, right? I'm not sure what direnv does with this recording functionality, but exiting the shell when interrupting a builtin doesn't seem like a great tradeoff to get it? |
|
In cases where the |
|
Right, and that sounds like a good thing to avoid. But isn't quitting the terminal at any time during the entire session worse? I would expect this would be a magnitudes more common situation? Anyway, I'm not trying to argue that such functionality isn't good and desired! I just initially got the impression that the exit-the-shell behaviour was considered an okay tradeoff rather than a bug, and wanted to highlight that at least for certain users (me) it certainly breaks the day-to-day usage pretty badly. |
|
I'd rather find a solution that works for both scenarios. Personally I am never hitting that issue but encounter the cancel one quite a lot. Current workaround: Replace _direnv_hook() {
local previous_exit_status=$?;
eval "$(direnv export bash)";
return $previous_exit_status;
};
if ! [[ "${PROMPT_COMMAND:-}" =~ _direnv_hook ]]; then
PROMPT_COMMAND="_direnv_hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
fi |
|
side note: zsh is behaving properly |
|
I've been seeing this exact issue for a couple of days now. My terminal was unexpectedly closed after starting fzf and then cancelling it by pressing ^C. Finally got some time to look at it and found the culprit in trap commands inside Pressing Ctrl-C during any subshell evaluation terminates the shell. Another problem with the the hook is that it's overwriting any user defined SIGINT traps. |
|
So is this a bash bug after all? Should I switch to zsh? Kind of a drag to carefully use old releases, though it's made a lot easier with asdf-vm. I'm on Fedora 32. |
|
Yep, it's a bash bug. Not sure if it has been reported yet. |
|
I've reported the problem yesterday before finding this issue. https://savannah.gnu.org/support/index.php?110335 |
|
Chet Ramey has released bash 5.1 which is supposed to fix this issue. |
|
Anyone using nixpkgs who wants this fixed real bad like I did: NixOS/nixpkgs#107354 (bash: 5.0 -> 5.1) |
|
Sorry I dropped the ball on following up on a ton of this; thanks @roberth for reporting to bash directly. it is fixed in bash 5.1; but folks using mac's bash 3.x (though I have not tested on the latest-and-greatest-mac-update) will potentially still encounter the problem (even with latest direnv). Using the workaround above #627 (comment) (removing the Thanks! |
See: direnv/direnv#627 Apparently fixed in bash 5.1 If I hit ^C in uselect, this would exit the shell. This was driving me nutso!
|
Just noting here my seemingly related issue which was also fixed by upgrading bash: I had this annoying problem that simply holding down |
Also attempt workaround direnv/direnv#627
Describe the bug
With direnv hook enabled in a shell-session, calling
read ansfollowed by a ctrl+c kills bothreadand current shell-session (occurs on both Mac and Archlinux systems)Further testing on Archlinux:
Exit code of ctrl+c from
read ans(on archlinux) yields 130, and is followed through to shell.To Reproduce
Steps to reproduce the behavior:
eval "$(direnv hook bash)"<ctrl+c>Expected behavior
bash shell-session should not terminate.
Environment
Additional context
Ran the test as root on archlinux; it did not terminate my shell-session.
The text was updated successfully, but these errors were encountered: