commit cd697e419ba240e22f29870f7e9c26503e8f7d15
parent 198c5664dedb07351710aaf7712b2e1d39bbd9d7
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date: Fri, 30 Oct 2020 22:22:03 +0100
Safe overwritting
Diffstat:
7 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/category b/category
@@ -7,7 +7,7 @@
# Set the project name, adding .git if necessary
p=$(echo "$1" | sed 's/\.git$\|$/.git/i')
-[ ! -d "$p" ] && echo "$p not found."
+[ ! -d "$p" ] && echo "$p not found." && exit 1
[ -n "$2" ] && echo "$2" > "$p/category" \
|| rm -f "$p/category"
diff --git a/description b/description
@@ -6,6 +6,6 @@
# Set the project name, adding .git if necessary
p=$(echo "$1" | sed 's/\.git$\|$/.git/i')
-[ ! -d "$p" ] && echo "$p not found."
+[ ! -d "$p" ] && echo "$p not found." && exit 1
echo "$2" > "$p/description"
diff --git a/init b/init
@@ -6,6 +6,8 @@
# Set the project name, adding .git if necessary
p=$(echo "$1" | sed 's/\.git$\|$/.git/i')
+[ -e "$p" ] && echo "$p is already a file or directory." && exit 1
+
# Create and initialise the project
mkdir "$p" && \
cd "$p" && \
diff --git a/make-private b/make-private
@@ -11,7 +11,7 @@ webdir="/srv/git/html"
dir="$(echo "$1" | sed 's/\.git$\|$/.git/i')"
web="/srv/git/html/$(basename "$dir" ".git")"
-[ ! -d "$dir" ] && echo "$dir not found."
+[ ! -d "$dir" ] && echo "$dir not found." && exit 1
[ ! -f "$dir/git-daemon-export-ok" ] && echo "$dir is already private." && exit
diff --git a/make-public b/make-public
@@ -11,7 +11,7 @@ defaultdir="/usr/local/share/doc/stagit"
# Set the project name, adding .git if necessary
dir=$(echo "$1" | sed 's/\.git$\|$/.git/i')
-[ ! -d "$dir" ] && echo "$dir not found."
+[ ! -d "$dir" ] && echo "$dir not found." && exit 1
[ -f "$dir/git-daemon-export-ok" ] && echo "$dir is already public." && exit
diff --git a/owner b/owner
@@ -6,6 +6,6 @@
# Set the project name, adding .git if necessary
p=$(echo "$1" | sed 's/\.git$\|$/.git/i')
-[ ! -d "$p" ] && echo "$p not found."
+[ ! -d "$p" ] && echo "$p not found." && exit 1
echo "$2" > "$p/owner"
diff --git a/url b/url
@@ -6,6 +6,6 @@
# Set the project name, adding .git if necessary
p=$(echo "$1" | sed 's/\.git$\|$/.git/i')
-[ ! -d "$p" ] && echo "$p not found."
+[ ! -d "$p" ] && echo "$p not found." && exit 1
echo "$2" > "$p/url"