From 61276804d4741ef75ed1060fb083c86ee0fc60b3 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 25 Feb 2020 08:59:22 +0000 Subject: [PATCH] check no file exists at install destination --- install.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 4b83e32..1fd17bd 100755 --- a/install.sh +++ b/install.sh @@ -15,15 +15,19 @@ echo "Install directory: '$_install_dir'" echo "" for _file in ./src/* ; do + _destination="$_install_dir"$(basename "$_file") if [ $_uninstall -eq 0 ] ; then - echo "installing: $_file" - sudo cp "$_file" "$_install_dir" + if ! [ -e "$_destination" ] ; then + echo "installing: $_file" + sudo cp "$_file" "$_install_dir" + else + echo "file present - skipping: $_file" + fi elif [ $_uninstall -eq 1 ] ; then - _filename=$(basename "$_file") - # WARNING - need to ensure $_filename is not empty (/usrlocal/bin will be deleted) - if [ -n "$_filename" ]; then - echo "uninstalling: $_filename" - sudo rm "$_install_dir$_filename" + # WARNING - need to ensure $_filename is not empty (/usr/local/bin will be deleted) + if [ -n "$_destination" ] ; then + echo "uninstalling: $_destination" + sudo rm "$_install_dir$_destination" fi fi done