diff options
Diffstat (limited to 'kerl')
-rwxr-xr-x | kerl | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -1229,6 +1229,11 @@ list_has() return 1 } +path_usage() +{ + echo "usage: $0 path [<install_name>]" +} + list_usage() { echo "usage: $0 list <releases|builds|installations>" @@ -1549,6 +1554,39 @@ case "$1" in ;; esac ;; + path) + # Usage: + # kerl path + # # Print currently active installation path, else non-zero exit + # kerl path <install> + # Print path to installation with name <install>, else non-zero exit + if [ -z "$2" ]; then + activepath=$(get_active_path) + if [ -z "$activepath" ]; then + echo "No active kerl-managed erlang installation" + exit 1 + fi + echo "$activepath" + else + # There are some possible extensions to this we could + # consider, such as: + # - if 2+ matches: prefer one in a subdir from $PWD + # - prefer $KERL_DEFAULT_INSTALL_DIR + match= + for ins in $(list_print installations | cut -d' ' -f2); do + if [ "$(basename $ins)" = "$2" ]; then + if [ -z "$match" ]; then + match="$ins" + else + echo "Error: too many matching installations" >&2 + exit 2 + fi + fi + done + [ -n "$match" ] && echo "$match" && exit 0 + echo "Error: no matching installation found" >&2 && exit 1 + fi + ;; delete) if [ $# -ne 3 ]; then delete_usage |