From 0139d6cd919fdf70714792f5f33a6aa119afdc01 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 17 Jun 2020 17:51:52 -0400 Subject: Add errors to link.sh --- link.sh | 9 +++++++-- 1 file 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 -- cgit 1.4.1