bin_path(): use builtin commands and avoid which

This commit is contained in:
Tom "Ravi" Hale
2018-09-14 19:29:06 +07:00
parent f85b9a4727
commit e5da83665a
4 changed files with 10 additions and 10 deletions

View File

@@ -17,7 +17,7 @@ unalias git > /dev/null 2>&1
unset -f git > /dev/null 2>&1 unset -f git > /dev/null 2>&1
# Use the full path to git to avoid infinite loop with git function # Use the full path to git to avoid infinite loop with git function
export _git_cmd="$(\which git)" export _git_cmd="$(bin_path git)"
# Wrap git with the 'hub' github wrapper, if installed (https://github.com/defunkt/hub) # Wrap git with the 'hub' github wrapper, if installed (https://github.com/defunkt/hub)
if type hub > /dev/null 2>&1; then export _git_cmd="hub"; fi if type hub > /dev/null 2>&1; then export _git_cmd="hub"; fi

View File

@@ -14,3 +14,10 @@ function fail_if_not_git_repo() {
fi fi
return 0 return 0
} }
bin_path() {
if [[ -n ${ZSH_VERSION:-} ]];
then builtin whence -cp "$1" 2> /dev/null
else builtin type -P "$1"
fi
}

View File

@@ -108,7 +108,7 @@ fi
# Function wrapper around 'll' # Function wrapper around 'll'
# Adds numbered shortcuts to output of ls -l, just like 'git status' # Adds numbered shortcuts to output of ls -l, just like 'git status'
if [ "$shell_ls_aliases_enabled" = "true" ] && which ruby > /dev/null 2>&1; then if [ "$shell_ls_aliases_enabled" = "true" ] && builtin command -v ruby > /dev/null 2>&1; then
unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1 unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1
function ls_with_file_shortcuts { function ls_with_file_shortcuts {
local ll_output local ll_output

View File

@@ -21,13 +21,6 @@ fi
source "$scmbDir/test/support/test_helper.sh" source "$scmbDir/test/support/test_helper.sh"
source "$scmbDir/lib/scm_breeze.sh" source "$scmbDir/lib/scm_breeze.sh"
bin_path() {
if [ -n "${ZSH_VERSION:-}" ];
then where "$@" | tail -1
else which "$@"
fi
}
# Setup # Setup
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
oneTimeSetUp() { oneTimeSetUp() {