diff --git a/README.md b/README.md index 1d3a0b2..56881f2 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Works with: - GNU coreutils - curl - bash +- * If using MacOS you must use updated bash v4.x (brew install bash) --- diff --git a/bin/hashi-env b/bin/hashi-env deleted file mode 100755 index d7ac2d7..0000000 --- a/bin/hashi-env +++ /dev/null @@ -1,72 +0,0 @@ -#!/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 diff --git a/bin/hashi-env b/bin/hashi-env new file mode 120000 index 0000000..fb78337 --- /dev/null +++ b/bin/hashi-env @@ -0,0 +1 @@ +/Users/michael.keck/.hashi-env/libexec/hashi-env \ No newline at end of file diff --git a/libexec/hashi-env b/libexec/hashi-env new file mode 100755 index 0000000..78a40af --- /dev/null +++ b/libexec/hashi-env @@ -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