#!/usr/bin/env sh

curl --version > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "Could not find curl."; return 1; fi
__easy_install() {
    mkdir -p /tmp
    local user_dir="$( echo ~ )"
    local easy_home="${user_dir}/.easy.sh_easy"
    local easy_client_file="${easy_home}/client"
    local temp_easy_client="$( mktemp -t easy_clientXXX )"
    curl -k -f -s -S "https://easy.sh/client?client=easy&userMode=single&clientVersion=" > "${temp_easy_client}"\
     && source "${temp_easy_client}"\
     && easy --init "$1" "$2"\
     && cat "${temp_easy_client}" > "${easy_client_file}"
}
__easy_install "$1" "$2"
unset -f __easy_install
if [[ "$0" = "-bash" || "$0" = "-zsh" || "$0" = "x" ]]; then rm -f "`pwd`/x"; fi
