tools/autoinstall/before.sh

31 lines
579 B
Bash
Raw Permalink Normal View History

2024-01-09 15:48:11 +00:00
#!/usr/bin/env bash
action=${action:?}
2024-05-12 21:50:11 +00:00
# do nothing on some selected actions
if [ "$action" = "completions" ] || [ "$action" = "flatpak" ] || [ "$action" = "run" ]
2024-01-09 15:48:11 +00:00
then
return
2024-01-09 15:48:11 +00:00
fi
clean=${args[--clean]:-}
target=${args[target]:?}
if [ "$action" = "exe" ]
2024-01-09 15:48:11 +00:00
then
target="$HOME/.local/bin/$target"
fi
if [ -n "$clean" ] || [ -n "${AUTOINSTALL_CLEAN:-}" ]
then
echo "Cleaning $target"
2024-03-22 21:14:13 +00:00
# sanity checks
if [ -z "$target" ] || [ "$target" = "/" ] || [ "$target" = "$HOME" ] || [ "$target" = "$HOME/" ]
then
echo "Invalid target: '$target'"
exit 1
fi
2024-01-09 15:48:11 +00:00
rm -rf "$target"
fi