From b21c4430ec277587a05c18d00514b361d5fce780 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 25 Feb 2020 09:12:33 +0000 Subject: [PATCH] add option to overwrite --- install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1fd17bd..3228638 100755 --- a/install.sh +++ b/install.sh @@ -1,10 +1,13 @@ #!/bin/sh _install_dir="/usr/local/bin/" _uninstall=0 +_overwrite=0 for _arg in "$@" ; do if [ "$_arg" = "-u" ] || [ "$_arg" = "--uninstall" ] ; then _uninstall=1 + elif [ "$_arg" = "-o" ] || [ "$_arg" = "--overwrite" ] ; then + _overwrite=1 else echo "warning: unknown option." exit 1 @@ -17,7 +20,7 @@ echo "" for _file in ./src/* ; do _destination="$_install_dir"$(basename "$_file") if [ $_uninstall -eq 0 ] ; then - if ! [ -e "$_destination" ] ; then + if [ ! -e "$_destination" ] || [ "$_overwrite" -eq 1 ] ; then echo "installing: $_file" sudo cp "$_file" "$_install_dir" else