Skip to content

Commit

Permalink
Add confirmation before deleting .bak file. Add message when installa…
Browse files Browse the repository at this point in the history
…tion script ends.
  • Loading branch information
shaief committed Apr 20, 2015
1 parent 1cf7a9b commit bfbced2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ case $OSTYPE in
;;
esac

BACKUP_FILE=$CONFIG_FILE.bak

if [ -e $HOME/$BACKUP_FILE ]; then
echo "Backup file already exist. Make sure to backup your .bashrc before running this installation." >&2
while true
do
read -p "Would you like to overwrite the existing backup? this will delete your existing backup file [Y/N] " RESP
case $RESP
in
[yY])
break
;;
[nN])
echo "Installation have not started. Please come back soon!"
exit 1
;;
*)
echo "Unknown choice. Please enter [Y/N] "
continue
;;
esac
done
fi
test -w $HOME/$CONFIG_FILE &&
cp -a $HOME/$CONFIG_FILE $HOME/$CONFIG_FILE.bak &&
echo "Your original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak"
Expand Down Expand Up @@ -112,4 +135,5 @@ else
esac
done
done
echo "Installation finished successfully! Enjoy bash-it!"
fi

0 comments on commit bfbced2

Please sign in to comment.