diff --git a/.gitignore b/.gitignore index 8e14e7b..21cf940 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .*.s[a-w][a-z] +.idea diff --git a/evm b/evm index 99f94ea..1a979cc 100755 --- a/evm +++ b/evm @@ -14,7 +14,7 @@ else EVM_PS_SHELL="$SHELL" fi -VERSION="5.0.2" +VERSION="5.0.3" ERLANG_ORG="http://www.erlang.org/download/" ERLANG_URL="https://github.com" FILE_PATH="/erlang/otp/archive/OTP-" @@ -125,27 +125,59 @@ function _unzip_strip() { # shopt is a bash built-in command. Zsh, has setopt instead # so, set the command according to the type of shell (only supports bash and zsh) local SHOPT="shopt" - if [[ "$EVM_PS_SHELL" == *zsh ]]; then + if [[ "$EVM_PS_SHELL" == *zsh ]] || [[ "$(which $SHELL)" == *"/zsh" ]] ; then SHOPT="setopt" fi local zip="$1" local dest="${2:-.}" - local temp=$(mktemp -d) - + local -i _err=0 + local temp=$(mktemp -d) + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi unzip -d "$temp" "$zip" - mkdir -p "$dest" - $SHOPT -s dotglob + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi + mkdir -p "$dest" + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi + $SHOPT -s dotglob + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi local f=("$temp"/*) - - if (( ${#f[@]} == 1 )) && [[ -d "${f[0]}" ]] ; then - mv "$temp"/*/* "$dest" - else - mv "$temp"/* "$dest" - fi - - rm -rf "$temp" -} + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi + + if (( ${#f[@]} == 1 )) && [[ -d "${f[0]}" ]] ; then + mv "$temp"/*/* "$dest" + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi + + else + mv "$temp"/* "$dest" + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi + fi + rm -rf "$temp" + _err=$? + if [ ${_err} -ne 0 ] ; then + return ${_err} + fi +} # end _unzip_strip # This function will download the erlang version if needed, @@ -193,9 +225,17 @@ function evm_install() { # tar xvzf ~/.evm/erlang_tars/otp_src_R15B03-1.tar.gz --strip-components 1 -C otp_src_R15B03-1 local UNTAR_DIR=$DEFAULT_TAR_LOCATION$FOLDER_PREFIX$VER mkdir $UNTAR_DIR + # PARENT_COMMAND=$(ps -o comm= $PPID) + # >&2 echo PWD:$(PWD) PARENT_COMMAND:${PARENT_COMMAND} > $HOME/evm.log + local -i _err=0 _unzip_strip $DEFAULT_TAR_LOCATION$FILE_PREFIX$VER$FILE_EXTENSION $UNTAR_DIR - + _err=$? + if [ ${_err} -ne 0 ] ; then + echo "There was an error unzipping ... $UNTAR_DIR" + exit 1 + fi echo "Configuring... $UNTAR_DIR" + _err=0 # In zshell or other systems, the contents of the zip file # are expanded inside a new directory in the destination, @@ -203,8 +243,14 @@ function evm_install() { # or multiple and cd into the right place if [ $(ls -1 $UNTAR_DIR | wc -l) -gt 1 ]; then cd $UNTAR_DIR + _err=$? else cd $UNTAR_DIR/* # CD into the new subdirectory + _err=$? + fi + if [ ${_err} -ne 0 ] ; then + echo "There was an error going to directory unzipped ... $UNTAR_DIR" + exit 1 fi local INSTALL_DIR="$DEFAULT_INSTALL_LOCATION$FOLDER_PREFIX$VER" @@ -212,9 +258,23 @@ function evm_install() { # Multiple spaces becomes one space and spaces from begining of string are removed. EXTRA="$(echo "$EXTRA" | sed -E 's/[[:blank:]]+/ /g;s/^[[:blank:]]+//g')" chmod +X otp_build + _err=$? + if [ ${_err} -ne 0 ] ; then + echo "There was an error calling ... .chmod +X otp_build " + exit 1 + fi ./otp_build autoconf # To generate the configure file + _err=$? + if [ ${_err} -ne 0 ] ; then + echo "There was an error calling ... ./otp_build autoconf " + exit 1 + fi ./configure --prefix="$INSTALL_DIR" $EXTRA - + _err=$? + if [ ${_err} -ne 0 ] ; then + echo "There was an error calling ... ./configure --prefix="$INSTALL_DIR" $EXTRA" + exit 1 + fi # Block execution so the user can check if any dependency is missing # before continue with installation unless '-y' is passed along # with evm install command @@ -607,7 +667,7 @@ function evm() { _load ## Setup autocomplete -if [[ "$EVM_PS_SHELL" == *zsh ]]; then +if [[ "$EVM_PS_SHELL" == *zsh ]] || [[ "$(which $SHELL)" == *"/zsh" ]] ; then autoload bashcompinit bashcompinit fi @@ -622,14 +682,14 @@ function _evm_complete() { # DEBUG >&2 echo "ps:;$(ps | grep $$)" # DEBUG >&2 echo "EVM_PS_SHELL:;${EVM_PS_SHELL}" # DEBUG >&2 echo "who:;${0}" - if [[ "$EVM_PS_SHELL" == *bash ]] ; then + if [[ "$EVM_PS_SHELL" == *bash ]] || [[ "$(which $SHELL)" == *"/bash" ]] ; then # DEBUG >&2 echo "COMP_CWORD:;${COMP_CWORD};" i_comp_cword=$COMP_CWORD COMPREPLY=() # DEBUG >&2 echo "COMP_WORDS:;${COMP_WORDS};" cur=${COMP_WORDS[i_comp_cword]} prev=${COMP_WORDS[i_comp_cword-1]} - elif [[ "$EVM_PS_SHELL" == *zsh ]] ; then + elif [[ "$EVM_PS_SHELL" == *zsh ]] || [[ "$(which $SHELL)" == *"/zsh" ]] ; then # DEBUG >&2 echo "CURRENT:;${CURRENT};" # DEBUG >&2 echo "words:;${words};" # DEBUG >&2 echo "curcontext:;${curcontext};" @@ -643,7 +703,7 @@ function _evm_complete() { # DEBUG >&2 echo "cur:;${cur};" # DEBUG >&2 echo "prev:;${prev};" - if [[ "$EVM_PS_SHELL" == *bash ]] ; then + if [[ "$EVM_PS_SHELL" == *bash ]] || [[ "$(which $SHELL)" == *"/bash" ]] ; then # shellcheck disable=SC2086 if [ ${i_comp_cword} -eq 1 ] ; then # DEBUG >&2 echo "bash true 01" @@ -684,7 +744,7 @@ function _evm_complete() { ;; esac fi - elif [[ "$EVM_PS_SHELL" == *zsh ]] ; then + elif [[ "$EVM_PS_SHELL" == *zsh ]] || [[ "$(which $SHELL)" == *"/zsh" ]] ; then # shellcheck disable=SC2086 if [ ${i_comp_cword} -eq 1 ] ; then # DEBUG >&2 echo "zsh true 01"