From c08267e25d3d35d4a0ff90d52990c365ca35fa2f Mon Sep 17 00:00:00 2001 From: John D Pell Date: Wed, 26 Jan 2022 10:07:08 -0800 Subject: [PATCH] lib/helpers: eliminate assumptions about login shells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bash loads initialization files on Mac just the same as it does on Linux or WSL. Our previous assumptions were wrong, and my fix was alsö wrong because I made more assumptions! This patch eliminates the assumptions. Literally just load either the startup file the shell started with, or fall back to `~/.bashrc`. Don't check `shopt -q login_shell` and don't check `$OSTYPE` or anything else. --- lib/helpers.bash | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 5bd88f54..0ff56af1 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -654,14 +654,9 @@ function _bash-it-restart() { _about 'restarts the shell in order to fully reload it' _group 'lib' - local saved_pwd="${PWD}" init_file + local saved_pwd="${PWD}" init_file="${BASH_IT_BASHRC:-${HOME?}/.bashrc}" - if shopt -q login_shell; then - init_file=.bash_profile - else - init_file=.bashrc - fi - exec "${0/-/}" --rcfile <(echo "source \"$HOME/$init_file\"; cd \"$saved_pwd\"") + exec "${0/-/}" --rcfile <(echo "source \"${init_file}\"; cd \"$saved_pwd\"") } function _bash-it-reload() { @@ -669,15 +664,8 @@ function _bash-it-reload() { _group 'lib' pushd "${BASH_IT?}" > /dev/null || return - # shellcheck disable=SC1090 - if shopt -q login_shell; then - # shellcheck source-path=$HOME - source ~/.bash_profile - else - # shellcheck source-path=$HOME - source ~/.bashrc - fi + source "${BASH_IT_BASHRC:-${HOME?}/.bashrc}" popd > /dev/null || return }