From 2387c561e72fec591eb018ba064079c6cfe11687 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Sun, 2 May 2021 00:36:26 +0500 Subject: [PATCH] attempt to reduce lines by using OR instead of elif --- addcontact-menu.sh | 5 +---- contactsmenu.sh | 5 +---- osdetect.sh | 2 +- savepass.sh | 21 +-------------------- settings-menu.sh | 2 +- 5 files changed, 5 insertions(+), 30 deletions(-) diff --git a/addcontact-menu.sh b/addcontact-menu.sh index 55753b1..03540d4 100644 --- a/addcontact-menu.sh +++ b/addcontact-menu.sh @@ -11,12 +11,9 @@ echo "" printf 'Select contact type[1]: ' read -r CONTACT_TYPE -if [ "$CONTACT_TYPE" = "1" ] +if [ "$CONTACT_TYPE" = "1" ] || [ "$CONTACT_TYPE" = "" ] then source addcontact-bml.sh -elif [ "$CONTACT_TYPE" = "" ] - then - source addcontact-bml.sh elif [ "$CONTATC_TYPE" = "2" ] then echo "${red}WORK IN PROGRESS${reset}" diff --git a/contactsmenu.sh b/contactsmenu.sh index 21794e0..ed81d5d 100644 --- a/contactsmenu.sh +++ b/contactsmenu.sh @@ -18,10 +18,7 @@ then elif [ "$CONTACTS" = "3" ] then source deletecontact.sh -elif [ "$CONTACTS" = "4" ] -then - source mainmenu.sh -elif [ "$CONTACTS" = "back" ] +elif [ "$CONTACTS" = "4" ] || [ "$CONTACTS" = "back" ] then sleep 0.2 source mainmenu.sh diff --git a/osdetect.sh b/osdetect.sh index 033f8f2..603362e 100644 --- a/osdetect.sh +++ b/osdetect.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ "uname -r | grep -oE microsoft" = "microsoft" ] +if [ "uname -r | grep -oE microsoft" = "microsoft" ] || [ "uname -r | grep -oE Microsoft" = "Microsoft" ] then WSL=true #echo "${red}WSL Not Supported!${reset}" 1>&2 diff --git a/savepass.sh b/savepass.sh index 22cbbe8..5eb6d49 100644 --- a/savepass.sh +++ b/savepass.sh @@ -3,7 +3,7 @@ then if [ "$LOGIN" = "0" ] then read -p 'Do you want to save login? [y/N] ' SAVE_LOGIN - if [ "$SAVE_LOGIN" = "Y" ] + if [ "$SAVE_LOGIN" = "Y" ] || [ "$SAVE_LOGIN" = "y" ] then read -s -p 'Enter Pin: ' PIN echo "" @@ -22,25 +22,6 @@ then echo "${red}Pin do not match${reset}" source savepass.sh fi - elif [ "$SAVE_LOGIN" = "y" ] - then - read -s -p 'Enter Pin: ' PIN - echo "" - read -s -p 'Repeat Pin: ' REPEAT_PIN - if [ "$PIN" = "$REPEAT_PIN" ] - then - echo "" - echo "Your credentials are ${lightgreen}encrypted${reset} and saved in $CREDENTIALS" - BML_USERNAME=$(echo "${BML_USERNAME}" | openssl enc -e -des3 -base64 -pass pass:${PIN} -pbkdf2) - BML_PASSWORD=$(echo "${BML_PASSWORD}" | openssl enc -e -des3 -base64 -pass pass:${PIN} -pbkdf2) - echo "BML_USERNAME='${BML_USERNAME}'" > $CREDENTIALS - echo "BML_PASSWORD='${BML_PASSWORD}'" >> $CREDENTIALS - - else - echo "" - echo "${red}Pin do not match${reset}" - source savepass.sh - fi else : fi diff --git a/settings-menu.sh b/settings-menu.sh index d549f4f..5d060d3 100644 --- a/settings-menu.sh +++ b/settings-menu.sh @@ -14,7 +14,7 @@ then elif [ "$SETTINGS" = "2" ] then source changepassword.sh -elif [ "$SETTINGS" = "back" ] +elif [ "$SETTINGS" = "2" ] || [ "$SETTINGS" = "back" ] then source mainmenu.sh elif [ "$SETTINGS" = "clear" ]