From a544d9827d2eb8df085e6689208417c30578f29f Mon Sep 17 00:00:00 2001
From: Salt <rehashedsalt@cock.li>
Date: Sun, 10 Feb 2019 12:29:23 -0600
Subject: [PATCH] tmp: Update help text, add more directory permissions
 checking

---
 tmp | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tmp b/tmp
index bffded1..8420870 100755
--- a/tmp
+++ b/tmp
@@ -34,7 +34,7 @@ while getopts ":h" opt; do
 			cat << EOF
 Usage: $name [TEMPLATE]
 Create a temporary directory, copying the folder [TEMPLATE] from
-~/Templates/tmp, if it exists.
+[XDG_TEMPLATES_DIR|~/Templates]/tmp, if it exists.
 
   -h			Show this help text
 
@@ -59,12 +59,16 @@ if [ -n "$1" ]; then
 	fi
 	unset userdirs
 	copydir="${XDG_TEMPLATES_DIR:-~/Templates}/tmp/$1"
-	if [ -d "$copydir" ]; then
-		log "Using template \"$1\""
-		cp -r "$copydir"/* "$tmpdir"
-	else
+	if ! [ -d "$copydir" ]; then
 		log "Could not find template directory \"$copydir\""
+		exit 3
 	fi
+	if ! [ -r "$copydir" ]; then
+		log "Cannot read template directory \"$copydir\""
+		exit 4
+	fi
+	log "Using template \"$1\""
+	cp -r "$copydir"/* "$tmpdir"
 	unset copydir
 fi