diff options
author | June McEnroe <june@causal.agency> | 2020-06-17 17:51:52 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-06-17 17:51:52 -0400 |
commit | 4deb5379a9eb9dd10d2ddcf850a48d0e9228a950 (patch) | |
tree | 81eb0a835e2776d33a01983bcdf6eb8ef28b9092 | |
parent | Add simpler aes tr script (diff) | |
download | src-4deb5379a9eb9dd10d2ddcf850a48d0e9228a950.tar.gz src-4deb5379a9eb9dd10d2ddcf850a48d0e9228a950.zip |
Add errors to link.sh
Diffstat (limited to '')
-rw-r--r-- | link.sh | 9 |
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 |