Skip to content
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

Exiting fish from a keybinding which calls a function #7967

Closed
enricozb opened this issue May 2, 2021 · 2 comments
Closed

Exiting fish from a keybinding which calls a function #7967

enricozb opened this issue May 2, 2021 · 2 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@enricozb
Copy link
Contributor

enricozb commented May 2, 2021

Environment

version: fish, version 3.2.1
uname: Linux xibalba 5.11.16-arch1-1 #1 SMP PREEMPT Wed, 21 Apr 2021 17:22:13 +0000 x86_64 GNU/Linux
term: alacritty

The behavior I'm reporting still occurs under sh -c 'env HOME=$(mktemp -d) fish'.

Problem & Reproduction

The following keybinding correctly exits the shell when typing ctrl+t:

bind \ct exit

However, the following keybinding does not exit the shell when typing ctrl+t:

function myexit
  exit
end
bind \ct myexit

Why is this the case?

@faho
Copy link
Member

faho commented May 2, 2021

The exit builtin doesn't immediately exit, it marks the session for exit so fish has a chance to clean up, e.g. to fire the exit handlers and such.

In a binding, you're still in the read loop, and it only checks the "session should exit" flag the next run through, so trying to run any command then exits.

Just exit works because there's also an exit bind function, so bind \ct exit does the equivalent of commandline -f exit - which also works here as a workaround.

@faho faho closed this as completed in 202e5e5 May 2, 2021
@faho faho added this to the fish 3.3.0 milestone May 2, 2021
@faho faho added the bug Something that's not working as intended label May 2, 2021
@enricozb
Copy link
Contributor Author

enricozb commented May 2, 2021

Thanks for the explanation.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants