git-shell-commands/rm

22 lines
471 B
Text
Raw Normal View History

2023-09-09 10:38:39 +02:00
#!/bin/bash
set -euo pipefail
IFS=$'\n'
cd ~git
source git-shell-commands/util.sh
arguments 1 "$#"
origin="$(repo_name_existing "$1")"
if [ -L "$origin" ]; then
printf '%s\n' "Removed '$origin' (symlink, not asking for confirmation)."
rm -rf "$origin"
else
printf '%s' "Are you sure you want to delete '$origin'? (y/N) "
read confirm
case $confirm in
y*|Y*) rm -rf "$origin"; printf '%s\n' "Removed '$origin'."; ;;
*) printf '%s\n' "Cancelling."; ;;
esac
fi