summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-06-17 17:51:52 -0400
committerJune McEnroe <june@causal.agency>2020-06-17 17:51:52 -0400
commit0139d6cd919fdf70714792f5f33a6aa119afdc01 (patch)
tree64f110d3b57749bcbd19bcdd047b95c5eddd23ef
parentAdd simpler aes tr script (diff)
downloadsrc-0139d6cd919fdf70714792f5f33a6aa119afdc01.tar.gz
src-0139d6cd919fdf70714792f5f33a6aa119afdc01.zip
Add errors to link.sh
-rw-r--r--link.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/link.sh b/link.sh
index d74f4788..6763f2e0 100644
--- a/link.sh
+++ b/link.sh
@@ -1,10 +1,15 @@
 #!/bin/sh
 set -eu
 
+die() {
+	echo "$*"
+	exit 1
+}
+
 if [ $# -eq 1 ]; then
 	link=$1
 	file="${PWD}/home/${link#${HOME}/}"
-	[ ! -f "$file" ]
+	[ ! -f "$file" ] || die "${file} exists"
 	mkdir -p "${file%/*}"
 	mv "$link" "$file"
 fi
@@ -13,6 +18,6 @@ find home -type f | while read -r find; do
 	file="${PWD}/${find}"
 	link="${HOME}/${find#home/}"
 	mkdir -p "${link%/*}"
-	[ \( -f "$link" -a -L "$link" \) -o ! -f "$link" ]
+	[ \( -f "$link" -a -L "$link" \) -o ! -f "$link" ] || die "${link} exists"
 	ln -fs "$file" "$link"
 done