add option to overwrite

This commit is contained in:
Ray Elliott 2020-02-25 09:12:33 +00:00
parent 38b5501628
commit b21c4430ec
1 changed files with 4 additions and 1 deletions

View File

@ -1,10 +1,13 @@
#!/bin/sh #!/bin/sh
_install_dir="/usr/local/bin/" _install_dir="/usr/local/bin/"
_uninstall=0 _uninstall=0
_overwrite=0
for _arg in "$@" ; do for _arg in "$@" ; do
if [ "$_arg" = "-u" ] || [ "$_arg" = "--uninstall" ] ; then if [ "$_arg" = "-u" ] || [ "$_arg" = "--uninstall" ] ; then
_uninstall=1 _uninstall=1
elif [ "$_arg" = "-o" ] || [ "$_arg" = "--overwrite" ] ; then
_overwrite=1
else else
echo "warning: unknown option." echo "warning: unknown option."
exit 1 exit 1
@ -17,7 +20,7 @@ echo ""
for _file in ./src/* ; do for _file in ./src/* ; do
_destination="$_install_dir"$(basename "$_file") _destination="$_install_dir"$(basename "$_file")
if [ $_uninstall -eq 0 ] ; then if [ $_uninstall -eq 0 ] ; then
if ! [ -e "$_destination" ] ; then if [ ! -e "$_destination" ] || [ "$_overwrite" -eq 1 ] ; then
echo "installing: $_file" echo "installing: $_file"
sudo cp "$_file" "$_install_dir" sudo cp "$_file" "$_install_dir"
else else