diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index 3043f1e..7b00f88 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -1,8 +1,11 @@ #!/usr/bin/env bash # MIT (c) Wenxuan Zhang -forgit::error() { printf "%b[Error]%b %s\n" '\e[0;31m' '\e[0m' "$@" >&2; return 1; } -forgit::warn() { printf "%b[Warn]%b %s\n" '\e[0;33m' '\e[0m' "$@" >&2; } +# all commands are prefixed with the command built-in. This prevents the wrong +# commands getting executed in case a user added a shell alias with the same name. + +forgit::error() { command printf "%b[Error]%b %s\n" '\e[0;31m' '\e[0m' "$@" >&2; return 1; } +forgit::warn() { command printf "%b[Warn]%b %s\n" '\e[0;33m' '\e[0m' "$@" >&2; } # determine installation path if [[ -n "$ZSH_VERSION" ]]; then @@ -12,7 +15,7 @@ if [[ -n "$ZSH_VERSION" ]]; then 0="${${(M)0:#/*}:-$PWD/$0}" FORGIT_INSTALL_DIR="${0:h}" elif [[ -n "$BASH_VERSION" ]]; then - FORGIT_INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")" + FORGIT_INSTALL_DIR="$(command dirname -- "${BASH_SOURCE[0]}")" else forgit::error "Only zsh and bash are supported" fi @@ -25,9 +28,8 @@ FORGIT="$FORGIT_INSTALL_DIR/bin/git-forgit" unexported_vars=0 # Set posix mode in bash to only get variables, see #256. [[ -n "$BASH_VERSION" ]] && set -o posix -set | awk -F '=' '{ print $1 }' | grep FORGIT_ | while read -r var; do - if ! export | grep -q "\(^$var=\|^export $var=\)"; then - if [[ $unexported_vars == 0 ]]; then +set | command awk -F '=' '{ print $1 }' | command grep FORGIT_ | while read -r var; do + if ! export | command grep -q "\(^$var=\|^export $var=\)"; then if [[ $unexported_vars == 0 ]]; then forgit::warn "Config options have to be exported in future versions of forgit." forgit::warn "Please update your config accordingly:" fi