From 2655b39e5b3bbc177714701d77383a4384749ab2 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Tue, 14 Jul 2015 10:04:09 -0500 Subject: [PATCH] Confirm targets exist before linking Targets *might* exist in Git, but not in the work tree. (especially when initially cloning) --- yadm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/yadm b/yadm index 1eefb7a..834656b 100755 --- a/yadm +++ b/yadm @@ -117,11 +117,13 @@ function alt() { #; for every file which matches the above regex, create a symlink for tracked_file in $(git ls-files | sort); do tracked_file="$YADM_WORK/$tracked_file" - if [[ $tracked_file =~ $match ]] ; then - new_link="${BASH_REMATCH[1]}" - debug "Linking $tracked_file to $new_link" - [ -n "$LOUD" ] && echo "Linking $tracked_file to $new_link" - ln -fs "$tracked_file" "$new_link" + if [ -e "$tracked_file" ] ; then + if [[ $tracked_file =~ $match ]] ; then + new_link="${BASH_REMATCH[1]}" + debug "Linking $tracked_file to $new_link" + [ -n "$LOUD" ] && echo "Linking $tracked_file to $new_link" + ln -fs "$tracked_file" "$new_link" + fi fi done