diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 532eb61..e82803e 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -29,15 +29,15 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is an alias"; fi # Store original alias local original_alias="$(whence $cmd)" - # Remove alias, so that which can return binary + # Remove alias, so that we can find binary unalias $cmd # Detect original $cmd type, and escape case "$(type $cmd 2>&1)" in # Escape shell builtins with 'builtin' *'is a shell builtin'*) local escaped_cmd="builtin $cmd";; - # Get full path for files with 'which' - *) local escaped_cmd="$(\which $cmd)";; + # Get full path for files with 'find_binary' function + *) local escaped_cmd="$(find_binary $cmd)";; esac # Expand original command into full path, to avoid infinite loops @@ -62,8 +62,8 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e *) if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is an executable file"; fi # Otherwise, command is a regular script or binary, - # and the full path can be found from 'which' - alias $cmd="exec_scmb_expand_args $(\which $cmd)";; + # and the full path can be found with 'find_binary' function + alias $cmd="exec_scmb_expand_args $(find_binary $cmd)";; esac done # Clean up diff --git a/lib/scm_breeze.sh b/lib/scm_breeze.sh index 0dc30ce..8cb2b1a 100644 --- a/lib/scm_breeze.sh +++ b/lib/scm_breeze.sh @@ -12,11 +12,15 @@ disable_nullglob() { if [ $shell = "zsh" ]; then unsetopt NULL_GLOB; else shopt # Alias wrapper that ignores errors if alias is not defined. _alias(){ alias "$@" 2> /dev/null; } -if [ $shell = "zsh" ]; then - export GIT_BINARY=$(type -p git | sed 's/git is //' | head -1) -else - export GIT_BINARY=$(type -P git) -fi +find_binary(){ + if [ $shell = "zsh" ]; then + type -p "$1" | sed "s/$1 is //" | head -1 + else + type -P "$1" + fi +} + +export GIT_BINARY=$(find_binary git) # Updates SCM Breeze from GitHub. update_scm_breeze() {