Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Works with:
- GNU coreutils
- curl
- bash
- * If using MacOS you must use updated bash v4.x (brew install bash)

---

Expand Down
72 changes: 0 additions & 72 deletions bin/hashi-env

This file was deleted.

1 change: 1 addition & 0 deletions bin/hashi-env
72 changes: 72 additions & 0 deletions libexec/hashi-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

set -e

if [ "$1" = "--debug" ]; then
export HASHIENV_DEBUG=1
shift
fi

if [ -n "${HASHIENV_DEBUG:-}" ]; then
export PS4='+ [${BASH_SOURCE##*/}:${LINENO}] '
set -x
fi

abort() {
{ if [ "$#" -eq 0 ]; then cat -
else echo "hashi-env: $*"
fi
} >&2
exit 1
}

source "$(dirname -- ${BASH_SOURCE[0]})/../env.sh"
HASHIENV_ROOT="${HASHIENV_ROOT%/}"
export HASHIENV_ROOT

eval "$("${HASHIENV_ROOT}/scripts/path-add" PATH "${HASHIENV_ROOT}/libexec")"
hash -r
mkdir -p "${HASHIENV_ROOT}/versions"
touch "${HASHIENV_ROOT}/version"
mkdir -p "${HASHIENV_ROOT}/shims"

# Check for help docs
subcommand="$1"
case "$subcommand" in
"" )
{
hashi-env---version
hashi-env---help
} | abort
;;

-v | --version )
exec hashi-env-version
;;

-h | --help )
exec hashi-env-help
;;

* )
command_path="$(command -v "hashi-env-$subcommand" || true)"
if [ -z "$command_path" ]; then
if [ "$command" == "shell" ]; then
abort "shell integration not enabled. Run 'hashi-env init' for instructions."
else
abort "no such command '$subcommand'"
fi
fi

shift 1

if [ "$1" = --help ]; then
if [[ "$subcommand" == "sh-"* ]]; then
echo "hashi-env help \"$subcommand\""
else
exec hashi-env-help "$subcommand"
fi
else
exec "$command_path" "$@"
fi
esac