zsh plugin: exit with an error if bin path cannot be determined

This commit is contained in:
carlfriedrich 2022-10-24 14:08:11 +02:00
parent 58882fd6ba
commit b2d24138df

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# MIT (c) Wenxuan Zhang
forgit::warn() { printf "%b[Warn]%b %s\n" '\e[0;33m' '\e[0m' "$@" >&2; }
forgit::error() { printf "%b[Error]%b %s\n" '\e[0;31m' '\e[0m' "$@" >&2; return 1; }
# set installation path
if [[ -n "$ZSH_VERSION" ]]; then
@ -13,12 +13,11 @@ if [[ -n "$ZSH_VERSION" ]]; then
elif [[ -n "$BASH_VERSION" ]]; then
FORGIT_INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
else
forgit::warn "Only zsh and bash are fully supported"
fi
if [[ -n "$FORGIT_INSTALL_DIR" ]]; then
export FORGIT_INSTALL_DIR
forgit::error "Only zsh and bash are supported"
fi
export FORGIT_INSTALL_DIR
# register shell functions
forgit::log() {
"$FORGIT_INSTALL_DIR/bin/git-forgit" log "$@"
}