1- #! /bin/sh
1+ #! /bin/bash
22
33set -e
4+ y_regex=" ^([y|Y][eE][sS]|[y|Y])$"
45
56# Copy commit.sh to the bin directory
67if ! sudo cp commit /usr/local/bin/; then
78 echo " Error: Failed to copy commit script to /usr/local/bin/"
89 exit 1
910fi
1011
12+ # Copy commit manual to man directory
13+ # Installation should not stop incase it fails, only a warning
14+ if ! sudo cp commit.1 /usr/local/man/man1; then
15+ echo " Failed to add commit man page to system"
16+ fi
17+
1118# Check if git is installed in the system
1219
1320if ! command -v git > /dev/null 2>&1 ; then
1421 echo -e " Git is not installed in your system \n Do you want to install it? (y/n): "
1522
1623 read -r git_choice
1724
18- if [[ $git_choice == ' y ' || $git_choice == ' Y ' ]]; then
25+ if [[ $git_choice =~ $y_regex ]]; then
1926 echo " This process may take *alot* of time, please be patient and make sure you have stable internet connection"
2027 chmod +x git_install.sh
2128 ./git_install.sh
2835# Create a validation regex that will be used to validate if the email is correct or not
2936# This only checks for the syntax and not deliverability
3037
31- regex =" ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
38+ email_regex =" ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
3239
3340# Ask if the user will like to enter other details or will like to continue with the system configuration
3441
3542read -rp " Do you want to enter your details(y/n): " detail_choice
3643
37- if [[ $detail_choice == ' y ' || $detail_choice == ' Y ' ]]; then
44+ if [[ $detail_choice =~ $y_regex ]]; then
3845 # Prompt for Git username
3946 read -rp " Enter Git username: " username
4047
@@ -54,7 +61,7 @@ if [[ $detail_choice == 'y' || $detail_choice == 'Y' ]]; then
5461 fi
5562
5663 # Validate the email is correct
57- if [[ ! $email =~ $regex ]]; then
64+ if [[ ! $email =~ $email_regex ]]; then
5865 echo " Error: Your email is invalid"
5966 exit 1
6067 fi
0 commit comments