bashrc_dispatch
bashrc_dispatch copied to clipboard
Incompatible with bash_completion from Homebrew
This line in .bashrc_once causes new shells to hang.
if [ -x /usr/local/bin/brew ]; then
export PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
fi
The most recent commit, d0bfcb8759, may have fixed this. If not, also try removing the symlink from ~/.profile . I should have a chance to test directly a little later.
Can't replicate this. But I don't know what your "brew --prefix
/etc/bash_completion" is referring to - I tried various brew and random bash_completions I have on my system but didn't replicate the problem. Let me know if you have more info or if the latest version fixes anything.
The problem is that the .bashrc_once (or .bashrc_all or .bashrc_script) might spawn another bash process. It has nothing to do with Homebrew. When the second bash is spawned, it runs all the .bashrc_* again, but slips past your PID recursion protection. Try the following:
Use a simple script, ~/simplescript
#!/bin/bash
echo "Running script!"
exit 1
In .bashrc_once, add a call to this script .bashrc_once:
~/simplescript
Now start a new bash session, or run any bash script. It should recursively spawn bash processes (look with "ps a") each with a different PID, of course.
I think you can fix this by changing when you set the guard on the .bashrc_once invocation. Replace this:
[ -f "${PRF}bashrc_once" ] && [ -z "$BRCD_RANONCE" ] && . "${PRF}bashrc_once" && export BRCD_RANONCE=true
with this
[ -f "${PRF}bashrc_once" ] && [ -z "$BRCD_RANONCE" ] && export BRCD_RANONCE=true && . "${PRF}bashrc_once"
I don't think there should be a problem with this. If "export BRCD_RANONCE=true" fails, then bashrc_once will never be called, but maybe you've got bigger problems at that point.
Thanks for the hard work on this bash_dispatch tool! I love it.
Update. I don't think it's correct to have the environment variable "run-once" guards in the && chain. I replaced this:
[ -f "${PRF}bashrc_once" ] && [ -z "$BRCD_RANONCE" ] && export BRCD_RANONCE=true && . "${PRF}bashrc_once"
with this:
if [ -f "${PRF}bashrc_once" ] && [ -z "$BRCD_RANONCE" ]; then
export BRCD_RANONCE=true
. "${PRF}bashrc_once"
unset BRCD_RANONCE
fi
As I mentioned in the previous comment, you need to set BRCD_RANONCE
before sourcing bashrc_once
to avoid recursive calls if bashrc_once
invokes a bash script. In addition, you don't want them to be all &&'ed together. This is because the bashrc_once
statement could fail for whatever reason. If it does, then the environment variable BRCD_RANONCE
will remain set.