summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorC. McEnroe <june@causal.agency>2020-06-17 17:51:52 -0400
committerC. McEnroe <june@causal.agency>2020-06-17 17:51:52 -0400
commit4deb5379a9eb9dd10d2ddcf850a48d0e9228a950 (patch)
tree81eb0a835e2776d33a01983bcdf6eb8ef28b9092
parentAdd simpler aes tr script (diff)
downloadsrc-4deb5379a9eb9dd10d2ddcf850a48d0e9228a950.tar.gz
src-4deb5379a9eb9dd10d2ddcf850a48d0e9228a950.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