From 56233e436dbe48ddefb0a5805e2f8c467aa05577 Mon Sep 17 00:00:00 2001 From: Nyx <144965845+nnyyxxxx@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:47:08 -0400 Subject: [PATCH] Fix read problems (#546) Co-authored-by: nnyyxxxx --- tabs/applications-setup/setup-flatpak.sh | 6 +++--- tabs/utils/auto-login.sh | 8 ++++---- tabs/utils/bluetooth-control.sh | 2 +- tabs/utils/monitor-control/set_brightness.sh | 10 +++++----- tabs/utils/ssh.sh | 2 +- tabs/utils/user-account-manager/delete_user.sh | 2 +- tabs/utils/wifi-control.sh | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tabs/applications-setup/setup-flatpak.sh b/tabs/applications-setup/setup-flatpak.sh index 5a1cf60f..66f8a803 100644 --- a/tabs/applications-setup/setup-flatpak.sh +++ b/tabs/applications-setup/setup-flatpak.sh @@ -51,7 +51,7 @@ setup_flatpak() { if command -v flatpak >/dev/null 2>&1; then if ! flatpak remotes | grep -q "flathub"; then printf "%b\n" "${YELLOW}Detected Flatpak package manager but Flathub remote is not added. Would you like to add it? (y/n)${RC}" - read add_remote + read -r add_remote case "$add_remote" in [Yy]*) printf "%b\n" "Adding Flathub remote..." @@ -71,14 +71,14 @@ setup_flatpak() { # So in case the user wants to use a GUI siftware manager they can setup it here if [ "$DE" = "GNOME" ]; then printf "%b\n" "${YELLOW}Detected GNOME desktop environment. Would you like to install GNOME Software plugin for Flatpak? (y/n)${RC}" - read install_gnome + read -r install_gnome if [ "$install_gnome" = "y" ] || [ "$install_gnome" = "Y" ]; then "$ESCALATION_TOOL" "$PACKAGER" install -y gnome-software-plugin-flatpak fi # Useful for Debian KDE spin as well elif [ "$DE" = "KDE" ]; then printf "%b\n" "${YELLOW}Detected KDE desktop environment. Would you like to install KDE Plasma Discover backend for Flatpak? (y/n)${RC}" - read install_kde + read -r install_kde if [ "$install_kde" = "y" ] || [ "$install_kde" = "Y" ]; then "$ESCALATION_TOOL" "$PACKAGER" install -y plasma-discover-backend-flatpak fi diff --git a/tabs/utils/auto-login.sh b/tabs/utils/auto-login.sh index b5ce0131..80fee2df 100644 --- a/tabs/utils/auto-login.sh +++ b/tabs/utils/auto-login.sh @@ -16,7 +16,7 @@ list_sessions() { printf "9) i3 (i3.desktop)\n" printf "10) Custom session\n" printf "Enter your choice [1-10]: " - read session_choice + read -r session_choice case "$session_choice" in 1) session="gnome.desktop" ;; @@ -130,7 +130,7 @@ configure_or_remove_autologin() { printf "1) Add autologin\n" printf "2) Remove autologin\n" printf "Enter your choice [1-2]: " - read action_choice + read -r action_choice if [ "$action_choice" = "1" ]; then printf "Choose the display manager to configure:\n" @@ -139,7 +139,7 @@ configure_or_remove_autologin() { printf "3) SDDM\n" printf "4) LXDM\n" printf "Enter your choice [1-4]: " - read choice + read -r choice case "$choice" in 1) configure_lightdm ;; @@ -155,7 +155,7 @@ configure_or_remove_autologin() { printf "3) SDDM\n" printf "4) LXDM\n" printf "Enter your choice [1-4]: " - read choice + read -r choice case "$choice" in 1) remove_lightdm_autologin ;; diff --git a/tabs/utils/bluetooth-control.sh b/tabs/utils/bluetooth-control.sh index 8ad2e813..01fd5c32 100644 --- a/tabs/utils/bluetooth-control.sh +++ b/tabs/utils/bluetooth-control.sh @@ -99,7 +99,7 @@ prompt_for_mac() { done printf "0. Exit to main menu\n" printf "%s\n" "$prompt_msg" - read choice + read -r choice # Validate the choice if echo "$choice" | grep -qE '^[0-9]+$' && [ "$choice" -le "$((i - 1))" ] && [ "$choice" -gt 0 ]; then diff --git a/tabs/utils/monitor-control/set_brightness.sh b/tabs/utils/monitor-control/set_brightness.sh index ab97b70a..bd3b3d55 100644 --- a/tabs/utils/monitor-control/set_brightness.sh +++ b/tabs/utils/monitor-control/set_brightness.sh @@ -21,7 +21,7 @@ adjust_monitor_brightness() { done printf "Enter the number of the monitor (or 'q' to quit): " - read monitor_choice + read -r monitor_choice if [ "$monitor_choice" = "q" ]; then printf "%b\n" "${RED}Exiting...${RC}" @@ -31,14 +31,14 @@ adjust_monitor_brightness() { if ! echo "$monitor_choice" | grep -qE '^[0-9]+$'; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" printf "Press [Enter] to continue..." - read dummy + read -r dummy continue fi if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$#" ]; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" printf "Press [Enter] to continue..." - read dummy + read -r dummy continue fi @@ -51,7 +51,7 @@ adjust_monitor_brightness() { while true; do printf "Enter the new brightness value as a percentage (10 to 100, or 'q' to quit): " - read new_brightness_percentage + read -r new_brightness_percentage if [ "$new_brightness_percentage" = "q" ]; then printf "%b\n" "${RED}Exiting...${RC}" @@ -68,7 +68,7 @@ adjust_monitor_brightness() { new_brightness=$(awk "BEGIN {printf \"%.2f\", $new_brightness_percentage / 100}") printf "Set brightness for $monitor_name to $new_brightness_percentage%? (y/n): " - read confirm + read -r confirm if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then printf "%b\n" "${GREEN}Setting brightness for $monitor_name to $new_brightness_percentage%${RC}" execute_command "xrandr --output $monitor_name --brightness $new_brightness" diff --git a/tabs/utils/ssh.sh b/tabs/utils/ssh.sh index 98b8715c..17cac929 100644 --- a/tabs/utils/ssh.sh +++ b/tabs/utils/ssh.sh @@ -220,7 +220,7 @@ show_menu() { main() { while true; do show_menu - read choice + read -r choice case $choice in 1) ask_for_host_details ;; 2) show_available_hosts && printf "%b\n" "Enter the alias of the host to connect to: " && read -r host_alias; ssh $host_alias ;; diff --git a/tabs/utils/user-account-manager/delete_user.sh b/tabs/utils/user-account-manager/delete_user.sh index ef1a59c4..e776a063 100755 --- a/tabs/utils/user-account-manager/delete_user.sh +++ b/tabs/utils/user-account-manager/delete_user.sh @@ -13,7 +13,7 @@ username=$(promptUsername "" "non-root") || exit 1 if [ "$username" = "$USER" ]; then printf "%b\n" "${RED}Cannot delete the current user${RC}" printf "%b\n" "${RED}Press [Enter] to continue...${RC}" - read dummy + read -r dummy return fi diff --git a/tabs/utils/wifi-control.sh b/tabs/utils/wifi-control.sh index 71abcce5..295031bc 100755 --- a/tabs/utils/wifi-control.sh +++ b/tabs/utils/wifi-control.sh @@ -46,7 +46,7 @@ main_menu() { printf "6. Remove a WiFi connection\n" printf "0. Exit\n" printf "Choose an option: " - read choice + read -r choice case $choice in 1) wifi_on ;; @@ -132,13 +132,13 @@ prompt_for_network() { printf "0. Exit to main menu\n" printf "%s" "$prompt_msg" - read choice + read -r choice if [ "$choice" -ge 1 ] && [ "$choice" -lt "$i" ]; then ssid=$(sed -n "${choice}p" "$temp_file" | awk -F: '{print $1}') if [ "$action" = "connect" ]; then printf "Enter password for SSID %s: " "$ssid" - read password + read -r password printf "\n" nmcli dev wifi connect "$ssid" password "$password" && { printf "%b\n" "${GREEN}$success_msg${RC}"