diff options
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 |