diff --git a/setup/tue-env.bash b/setup/tue-env.bash index 26a48262f..fb5ec1235 100644 --- a/setup/tue-env.bash +++ b/setup/tue-env.bash @@ -119,18 +119,25 @@ options: dir=$(cat "$TUE_DIR"/user/envs/"$env") rm "$TUE_DIR"/user/envs/"$env" - if [ $PURGE == "false" ] + if [[ -d ${dir} ]] then - dir_moved=$dir.$(date +%F_%R) - mv "$dir" "$dir_moved" - # shellcheck disable=SC1078,SC1079 - echo """[tue-env] Removed environment '$env' -Moved environment directory of '$env' to '$dir_moved'""" + if [ $PURGE == "false" ] + then + dir_moved=$dir.$(date +%F_%R) + mv "${dir}" "${dir_moved}" + # shellcheck disable=SC1078,SC1079 + echo """[tue-env] Removed environment '${env}' +Moved environment directory from '${dir}' to '${dir_moved}'""" + else + rm -rf "${dir}" + # shellcheck disable=SC1078,SC1079 + echo """[tue-env] Removed environment '$env' +Purged environment directory '${dir}'""" + fi else - rm -rf "$dir" # shellcheck disable=SC1078,SC1079 - echo """[tue-env] Removed environment '$env' -Purged environment directory of '$env'""" + echo """[tue-env] Removed environment '${env}' +Environment directory '${dir}' didn't exist (anymore)""" fi elif [[ $cmd == "switch" ]]