From b3a97851e17d472c9bbb3e738647569c655cf6ea Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 24 Dec 2023 12:57:30 +0300 Subject: [PATCH] Feat: Delete a repository Mostly for deleting it from `locate-all.list`. --- delete | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 delete diff --git a/delete b/delete new file mode 100755 index 0000000..6002dc4 --- /dev/null +++ b/delete @@ -0,0 +1,28 @@ +#! /bin/sh + +if [ -z "$1" -o -n "$3" ]; then + echo "Usage: $0 /path/to/repo" >&2 + exit 1 +fi + +start_dir="`pwd`" && +path_to_repo="$1" && +cd "$path_to_repo" && +path_to_repo="`pwd`" && +cd "$start_dir" && + +cd "`dirname \"$0\"`" && +if ! grep -q "^$path_to_repo\$" locate-all.list; then + echo "$path_to_repo" is not a known repository >&2 + exit 1 +fi + +rm -rf "$path_to_repo" && + +tmpfile="`mktemp`" && +grep -v "^$path_to_repo\$" locate-all.list > "$tmpfile" && +if cmp -s mv "$tmpfile" locate-all.list; then + exec rm -f "$tmpfile" +else + exec mv "$tmpfile" locate-all.list +fi -- 2.39.5