diff --git a/utils.sh b/utils.sh index 4bf49ed2a42cddbba1c0af92a1953b8cf756addd..0e13cc54e6a3b196dc6213a4ad8396d4e26f5575 100755 --- a/utils.sh +++ b/utils.sh @@ -30,13 +30,13 @@ return_value="" #region User Check Functions ### - # Function to check if current username matches passed value. + # Checks if current username matches passed value. # In particular, is used to check if user is sudo/root user. ## function check_is_user () { # Check number of passed function args. - if [[ $# == 1 ]] + if [[ ${#} == 1 ]] then # Expected number of args passed. Continue. local username=$USER @@ -62,7 +62,7 @@ function check_is_user () { fi # Handle for too many args. - elif [[ $# > 1 ]] + elif [[ ${#} > 1 ]] then echo -e "${text_red}Too many args passed. Expected one arg, received ${#}.${text_reset}" exit 1 @@ -76,13 +76,13 @@ function check_is_user () { ### - # Function to check if current username does not match passed value. - # In particular, is used to check if user is sudo/root user. + # Checks if current username does not match passed value. + # In particular, is used to check if user is not sudo/root user. ## function check_is_not_user () { # Check number of passed function args. - if [[ $# == 1 ]] + if [[ ${#} == 1 ]] then # Expected number of args passed. Continue. local username=$USER @@ -108,7 +108,7 @@ function check_is_not_user () { fi # Handle for too many args. - elif [[ $# > 1 ]] + elif [[ ${#} > 1 ]] then echo -e "${text_red}Too many args passed. Expected one arg, received ${#}.${text_reset}" exit 1 @@ -131,7 +131,7 @@ function check_is_not_user () { function to_upper () { # Check number of passed function args. - if [[ $# > 0 ]] + if [[ ${#} > 0 ]] then # At least one arg passed. Loop through each one. return_value=() @@ -154,7 +154,7 @@ function to_upper () { function to_lower () { # Check number of passed function args. - if [[ $# > 0 ]] + if [[ ${#} > 0 ]] then # At least one arg passed. Loop through each one. return_value=() @@ -163,7 +163,6 @@ function to_lower () { return_value+=( $(echo "${arg}" | tr '[:upper:]' '[:lower:]') ) done - # No args passed. else echo -e "${text_red}Too few args passed. Expected one arg, received 0.${text_reset}" @@ -175,7 +174,7 @@ function to_lower () { ### - # Function to print out all available text colors provided by this script. + # Prints out all available text colors provided by this script. ## function display_text_colors () { echo ""