From 7bd9f8aee8d2fc793e616c35ab3d20c29c7b90a2 Mon Sep 17 00:00:00 2001 From: Nyx <144965845+nnyyxxxx@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:39:09 -0400 Subject: [PATCH] Fix bashisms (#512) Co-authored-by: nnyyxxxx --- .../fedora/nvidia-proprietary-driver-setup.sh | 4 ++-- tabs/utils/encrypt_decrypt_tool.sh | 12 ++++++------ tabs/utils/user-account-manager/add_to_group.sh | 3 ++- tabs/utils/user-account-manager/change_password.sh | 3 ++- tabs/utils/user-account-manager/delete_user.sh | 3 ++- tabs/utils/user-account-manager/remove_from_group.sh | 3 ++- tabs/utils/user-account-manager/utility_functions.sh | 11 +++++++---- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh b/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh index ef0ada8d..6f99eb6c 100755 --- a/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh +++ b/tabs/system-setup/fedora/nvidia-proprietary-driver-setup.sh @@ -52,7 +52,7 @@ installDriver() { $ESCALATION_TOOL dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y printf "%b\n" "${YELLOW}Building the drivers may take upto 5 minutes. Please don't kill the script!\n If the build failed try running the script again, select \"Remove Nvidia Drivers\" and reboot the system, then try installing drivers again.${RC}" - for i in {1..5}; do + for i in $(seq 1 5); do if checkDriverInstallation; then printf "%b\n" "${GREEN}Driver installed successfully.${RC}" printf "%b\n" "${GREEN}Installed driver version $(modinfo -F version nvidia)${RC}" @@ -91,4 +91,4 @@ printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free reposit checkEnv checkEscalationTool -userConfirmation +userConfirmation \ No newline at end of file diff --git a/tabs/utils/encrypt_decrypt_tool.sh b/tabs/utils/encrypt_decrypt_tool.sh index 48945b71..805cd911 100644 --- a/tabs/utils/encrypt_decrypt_tool.sh +++ b/tabs/utils/encrypt_decrypt_tool.sh @@ -54,8 +54,8 @@ encrypt_file() { echo "Enter the path for the encrypted file or directory:" read -r OUTPUT_PATH - echo "Enter the encryption password:" - read -s -r PASSWORD + printf "Enter the encryption password: " + read -r PASSWORD if [ -d "$INPUT_PATH" ]; then # Encrypt each file in the directory @@ -99,8 +99,8 @@ decrypt_file() { echo "Enter the path for the decrypted file or directory:" read -r OUTPUT_PATH - echo "Enter the decryption password:" - read -s -r PASSWORD + printf "Enter the decryption password: " + read -r PASSWORD if [ -d "$INPUT_PATH" ]; then # Decrypt each file in the directory @@ -145,8 +145,8 @@ main(){ *) echo "Invalid choice. Please try again." ;; esac - echo "Press [Enter] to continue..." - read -r + printf "Press [Enter] to continue..." + read -r dummy done } diff --git a/tabs/utils/user-account-manager/add_to_group.sh b/tabs/utils/user-account-manager/add_to_group.sh index dd8a2a74..8ef22c20 100755 --- a/tabs/utils/user-account-manager/add_to_group.sh +++ b/tabs/utils/user-account-manager/add_to_group.sh @@ -25,7 +25,8 @@ checkGroupAvailabe "$groups" "$available_groups" || exit 1 groups_to_add=$(echo "$groups" | tr ' ' ',') -read -p "Are you sure you want to add user $username to $groups_to_add? [Y/N]: " confirm +printf "Are you sure you want to add user $username to $groups_to_add? [Y/N]: " +read -r confirm confirmAction || exit 1 $ESCALATION_TOOL usermod -aG $groups_to_add "$username" diff --git a/tabs/utils/user-account-manager/change_password.sh b/tabs/utils/user-account-manager/change_password.sh index ef05a55b..b7278cf7 100755 --- a/tabs/utils/user-account-manager/change_password.sh +++ b/tabs/utils/user-account-manager/change_password.sh @@ -10,7 +10,8 @@ printf "%b\n" "${YELLOW}=================${RC}" username=$(promptUsername "" "root") || exit 1 password=$(promptPassword) || exit 1 -read -p "Are you sure you want to change password for $username? [Y/N]: " confirm +printf "Are you sure you want to change password for $username? [Y/N]: " +read -r confirm confirmAction || exit 1 echo "$username:$password" | $ESCALATION_TOOL chpasswd diff --git a/tabs/utils/user-account-manager/delete_user.sh b/tabs/utils/user-account-manager/delete_user.sh index cb68bdf9..ef1a59c4 100755 --- a/tabs/utils/user-account-manager/delete_user.sh +++ b/tabs/utils/user-account-manager/delete_user.sh @@ -17,7 +17,8 @@ if [ "$username" = "$USER" ]; then return fi -read -p "Are you sure you want to delete user $username? [Y/N]: " confirm +printf "Are you sure you want to delete user $username? [Y/N]: " +read -r confirm confirmAction || exit 1 $ESCALATION_TOOL userdel --remove "$username" 2>/dev/null diff --git a/tabs/utils/user-account-manager/remove_from_group.sh b/tabs/utils/user-account-manager/remove_from_group.sh index 4d3c65c3..c462e9d0 100755 --- a/tabs/utils/user-account-manager/remove_from_group.sh +++ b/tabs/utils/user-account-manager/remove_from_group.sh @@ -20,7 +20,8 @@ checkGroupAvailabe "$groups" "$user_groups" || exit 1 groups_to_remove=$(echo "$groups" | tr ' ' ',') -read -p "Are you sure you want to remove user $username from $groups_to_remove? [Y/N]: " confirm +printf "Are you sure you want to remove user $username from $groups_to_remove? [Y/N]: " +read -r confirm confirmAction || exit 1 $ESCALATION_TOOL usermod -rG $groups_to_remove "$username" diff --git a/tabs/utils/user-account-manager/utility_functions.sh b/tabs/utils/user-account-manager/utility_functions.sh index 0dedd7e6..b6af5f53 100755 --- a/tabs/utils/user-account-manager/utility_functions.sh +++ b/tabs/utils/user-account-manager/utility_functions.sh @@ -4,7 +4,8 @@ # Prompt for username promptUsername() { - read -p "Enter the username: " username + printf "Enter the username: " + read -r username checkEmpty "$username"; @@ -21,9 +22,11 @@ promptUsername() { # Prompt for password promptPassword() { stty -echo - read -p "Enter the password (PASSWORD IS HIDDEN): " password1 + printf "Enter the password (PASSWORD IS HIDDEN): " + read -r password1 echo >&2 - read -p "Re-enter the password (PASSWORD IS HIDDEN): " password2 + printf "Re-enter the password (PASSWORD IS HIDDEN): " + read -r password2 echo >&2 stty echo @@ -97,4 +100,4 @@ checkGroupAvailabe() { } checkEnv -checkEscalationTool +checkEscalationTool \ No newline at end of file