Skip to content

Commit

Permalink
(tue-env) check if evironment dir exists when removing
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Nov 13, 2023
1 parent 450149d commit 6f7b363
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions setup/tue-env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]]
Expand Down

0 comments on commit 6f7b363

Please sign in to comment.