From 4dc3f62f2747ca0d16538d7ca635a8b499b8ed7b Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 21 Apr 2014 10:16:59 +0200 Subject: [PATCH] lib.sh: link(): simplify file checks --- lib.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib.sh b/lib.sh index ba4e658..d19669b 100644 --- a/lib.sh +++ b/lib.sh @@ -2,7 +2,7 @@ # # Their setup.sh script sources this file. -# Copyright (C) 2009-2013 Simon Ruderich +# Copyright (C) 2009-2014 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -153,15 +153,14 @@ link() { # Abort if the target file exists and is no symbolic link. Prevents # overwriting real files. - if ( test -f "$target" && test ! -h "$target" ) || \ - ( test -s "$target" && test ! -h "$target" ); then + if test -e "$target" && test ! -h "$target"; then printf "link(): target '%s' exists already and is no symbolic link!" \ "$target" >&2 exit 1 fi - # Make sure the source exists (is file, directory or link). - if test ! -f "$source" && test ! -d "$source" && test ! -h "$source"; then + # Make sure the source exists. + if test ! -e "$source"; then printf "link(): source '%s' doesn't exist!" "$source" >&2 exit 1 fi -- 2.43.2