-
Notifications
You must be signed in to change notification settings - Fork 221
Preserve exit code in bash hook #72
base: master
Are you sure you want to change the base?
Conversation
Preserve the exit code from the previous command the user ran when exiting from the bash hook. This allows other commands in PROMPT_COMMAND to handle the exit code from the original user command.
Thanks for this pull request. This fixes the problem when fasd is the only thing modifying the prompt command. But if there are more prompt commands then each one has to do such exit code passing. Is there a common agreed upon way to do this in the Bash community / users? |
I'm not sure there is a common way to do this. I did some research and didn't find anything too helpful. Every prompt command should do be doing this to preserve the exit code, there's no other way. I did update my own handler the same way. |
I add fasd to the precmd array provided to me by bash-preexec and in fact they do something very similar as you can see from the link. This commit seems more appropriate for a third party bash lib like bash-preexec or if you had a library loading themes etc it would and should have a function for installing to the PROMPT_COMMAND. I know bash-git-prompt provides one, so ... just fyi. |
I roll my own prompt and don't use any bash frameworks right now. There were two commands in my PROMPT_COMMAND (fasd and one of my own), and I needed this fix in both places to properly handle the previous command's return code. I'm not sure it's reasonable to ask fasd users to install bash-preexec just to work around this issue. |
There are multiple ways to install fasd, but the initialization still needs to happen. Currently, fasd is broken in bash in that it doesn't maintain the exit code properly. This custom init removes the call to `fasd --init bash-hook` and replaces it with the version that would be generated once fasd PR Bash-it#72 is merged. See: clvv/fasd#72
@clvv howdy! I'm one of the maintainers of https://github.com/Bash-it/bash-it/. As noted in the linked PR and commit above, we have to work around this issue in fasd in order to get the correct exit status to work with inside themes and plugins and such. I'd really like to see this merged so we can simplify our plugin. |
There are multiple ways to install fasd, but the initialization still needs to happen. Currently, fasd is broken in bash in that it doesn't maintain the exit code properly. This custom init removes the call to `fasd --init bash-hook` and replaces it with the version that would be generated once fasd PR #72 is merged. See: clvv/fasd#72
There are multiple ways to install fasd, but the initialization still needs to happen. Currently, fasd is broken in bash in that it doesn't maintain the exit code properly. This custom init removes the call to `fasd --init bash-hook` and replaces it with the version that would be generated once fasd PR Bash-it#72 is merged. See: clvv/fasd#72
Preserve the exit code from the previous command the user ran when
exiting from the bash hook. This allows other commands in
PROMPT_COMMAND to handle the exit code from the original user command.