From e0917ffebce5bf1fa549420f8f2496d63c295e40 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 22 Mar 2013 21:13:45 -0400 Subject: [PATCH] Check if file still exists after link check --- zsh/lib/util | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zsh/lib/util b/zsh/lib/util index 5a942f58..16b30b36 100644 --- a/zsh/lib/util +++ b/zsh/lib/util @@ -4,15 +4,19 @@ function command_exists { command -v "$1" &> /dev/null } +# log to a central logfile (specified by its caller globally) function do_log { printf "[%s] %s: %s" "$(`basename $BASH_SOURCE`)" "`date`" "$1" >> $logfile } +# Check if a symlink exists before trying to create it function do_link { if [ -h "$2" ]; then rm "$2" fi - ln -sf "$1" "$2" + if [ ! -e "$2" ]; then + ln -sf "$1" "$2" + fi } # vim:set ft=zsh: