From 1fe60f55eb6cfc3741a3ffaaf1cbfdb97572a891 Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Sat, 11 Jan 2025 16:08:20 +0100 Subject: [PATCH] refact: fix (almost) all shellcheck errors the only files i didn't fix: - core/tabs/utils/ssh.sh (ref #996) - core/tabs/system-setup/arch/server-setup.sh --- .../applications-setup/android-debloat.sh | 2 +- .../applications-setup/browsers/librewolf.sh | 4 +-- .../communication-apps/discord-setup.sh | 4 +-- .../communication-apps/signal-setup.sh | 4 +-- .../tabs/applications-setup/dwmtitus-setup.sh | 4 +-- .../applications-setup/linutil-installer.sh | 2 +- .../applications-setup/linutil-updater.sh | 2 +- core/tabs/system-setup/arch/server-setup.sh | 3 +- core/tabs/system-setup/compile-setup.sh | 12 ++++---- core/tabs/system-setup/system-cleanup.sh | 2 +- core/tabs/utils/bluetooth-control.sh | 15 +++++----- core/tabs/utils/encrypt_decrypt_tool.sh | 24 +++++++-------- .../utils/monitor-control/set_brightness.sh | 4 +-- .../utils/monitor-control/set_resolutions.sh | 2 +- core/tabs/utils/ollama.sh | 5 ++-- core/tabs/utils/samba-ssh-setup.sh | 4 +-- core/tabs/utils/service-control.sh | 4 +-- core/tabs/utils/ssh.sh | 2 +- core/tabs/utils/timeshift.sh | 6 +++- .../user-account-manager/add_to_group.sh | 4 +-- .../user-account-manager/change_password.sh | 4 +-- .../utils/user-account-manager/delete_user.sh | 4 +-- .../user-account-manager/remove_from_group.sh | 6 ++-- core/tabs/utils/utility_functions.sh | 1 + core/tabs/utils/wifi-control.sh | 30 +++++++++---------- 25 files changed, 80 insertions(+), 74 deletions(-) diff --git a/core/tabs/applications-setup/android-debloat.sh b/core/tabs/applications-setup/android-debloat.sh index 632580239..1db9328bd 100644 --- a/core/tabs/applications-setup/android-debloat.sh +++ b/core/tabs/applications-setup/android-debloat.sh @@ -19,7 +19,7 @@ install_adb() { "$ESCALATION_TOOL" "$PACKAGER" add android-tools ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" exit 1 ;; esac diff --git a/core/tabs/applications-setup/browsers/librewolf.sh b/core/tabs/applications-setup/browsers/librewolf.sh index d8ed06b41..f69745021 100644 --- a/core/tabs/applications-setup/browsers/librewolf.sh +++ b/core/tabs/applications-setup/browsers/librewolf.sh @@ -8,7 +8,7 @@ installLibreWolf() { case "$PACKAGER" in apt-get|nala) "$ESCALATION_TOOL" "$PACKAGER" install -y gnupg lsb-release apt-transport-https ca-certificates - distro=`if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q " $(lsb_release -sc) "; then lsb_release -sc; else echo focal; fi` + distro=$(if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q "$(lsb_release -sc)"; then "$(lsb_release -sc)"; else echo 'focal'; fi) curl -fsSL https://deb.librewolf.net/keyring.gpg | "$ESCALATION_TOOL" gpg --dearmor -o /usr/share/keyrings/librewolf.gpg echo "Types: deb URIs: https://deb.librewolf.net @@ -49,4 +49,4 @@ Signed-By: /usr/share/keyrings/librewolf.gpg" | "$ESCALATION_TOOL" tee /etc/apt/ checkEnv checkEscalationTool checkAURHelper -installLibreWolf \ No newline at end of file +installLibreWolf diff --git a/core/tabs/applications-setup/communication-apps/discord-setup.sh b/core/tabs/applications-setup/communication-apps/discord-setup.sh index f96bd9f2e..0843a3732 100644 --- a/core/tabs/applications-setup/communication-apps/discord-setup.sh +++ b/core/tabs/applications-setup/communication-apps/discord-setup.sh @@ -17,7 +17,7 @@ installDiscord() { "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm discord ;; dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + "$ESCALATION_TOOL" "$PACKAGER" install -y "https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" "$ESCALATION_TOOL" "$PACKAGER" install -y discord ;; apk) @@ -36,4 +36,4 @@ installDiscord() { checkEnv checkEscalationTool -installDiscord \ No newline at end of file +installDiscord diff --git a/core/tabs/applications-setup/communication-apps/signal-setup.sh b/core/tabs/applications-setup/communication-apps/signal-setup.sh index 18c462b1c..48f72ddbd 100644 --- a/core/tabs/applications-setup/communication-apps/signal-setup.sh +++ b/core/tabs/applications-setup/communication-apps/signal-setup.sh @@ -8,7 +8,7 @@ installSignal() { case "$PACKAGER" in apt-get|nala) curl -fsSL https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg - cat signal-desktop-keyring.gpg | "$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null + "$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg < signal-desktop-keyring.gpg > /dev/null printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/signal-xenial.list "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" -y install signal-desktop @@ -39,4 +39,4 @@ installSignal() { checkEnv checkEscalationTool -installSignal \ No newline at end of file +installSignal diff --git a/core/tabs/applications-setup/dwmtitus-setup.sh b/core/tabs/applications-setup/dwmtitus-setup.sh index be23b9ad9..fa8277000 100755 --- a/core/tabs/applications-setup/dwmtitus-setup.sh +++ b/core/tabs/applications-setup/dwmtitus-setup.sh @@ -192,7 +192,7 @@ setupDisplayManager() { "$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" exit 1 ;; esac @@ -244,7 +244,7 @@ setupDisplayManager() { "$ESCALATION_TOOL" "$PACKAGER" install -y "$DM" ;; *) - printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}" + printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" exit 1 ;; esac diff --git a/core/tabs/applications-setup/linutil-installer.sh b/core/tabs/applications-setup/linutil-installer.sh index 13776fc3c..c5af50455 100755 --- a/core/tabs/applications-setup/linutil-installer.sh +++ b/core/tabs/applications-setup/linutil-installer.sh @@ -53,7 +53,7 @@ installLinutil() { ;; *) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - . $HOME/.cargo/env + . "$HOME/.cargo/env" ;; esac fi diff --git a/core/tabs/applications-setup/linutil-updater.sh b/core/tabs/applications-setup/linutil-updater.sh index 4e399a024..1ccf90903 100755 --- a/core/tabs/applications-setup/linutil-updater.sh +++ b/core/tabs/applications-setup/linutil-updater.sh @@ -17,7 +17,7 @@ updateLinutil() { zypper) "$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - . $HOME/.cargo/env + . "$HOME/.cargo/env" ;; apk) "$ESCALATION_TOOL" "$PACKAGER" add build-base diff --git a/core/tabs/system-setup/arch/server-setup.sh b/core/tabs/system-setup/arch/server-setup.sh index 913d5f61e..c2206f303 100755 --- a/core/tabs/system-setup/arch/server-setup.sh +++ b/core/tabs/system-setup/arch/server-setup.sh @@ -102,7 +102,7 @@ select_option() { ;; '[B') # Down arrow ((selected++)) - if [ $selected -ge $num_options ]; then + if [ $selected -ge "$num_options" ]; then selected=0 fi ;; @@ -183,6 +183,7 @@ keymap () { echo -ne " Please select key board layout from this list" # These are default key maps as presented in official arch repo archinstall + # shellcheck disable=SC1010 options=(us by ca cf cz de dk es et fa fi fr gr hu il it lt lv mk nl no pl ro ru se sg ua uk) select_option "${options[@]}" diff --git a/core/tabs/system-setup/compile-setup.sh b/core/tabs/system-setup/compile-setup.sh index bb6bb44a9..746d1d5f5 100755 --- a/core/tabs/system-setup/compile-setup.sh +++ b/core/tabs/system-setup/compile-setup.sh @@ -15,33 +15,33 @@ installDepend() { else printf "%b\n" "${GREEN}Multilib is already enabled.${RC}" fi - "$AUR_HELPER" -S --needed --noconfirm $DEPENDENCIES + "$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES" ;; apt-get|nala) COMPILEDEPS='build-essential' "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" dpkg --add-architecture i386 "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS + "$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS" ;; dnf) COMPILEDEPS='@development-tools' "$ESCALATION_TOOL" "$PACKAGER" update "$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS + "$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS" "$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686 ;; zypper) COMPILEDEPS='patterns-devel-base-devel_basis' "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install "$DEPENDENCIES" "$COMPILEDEPS" "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit ;; apk) "$ESCALATION_TOOL" "$PACKAGER" add build-base multitail tar tree trash-cli unzip cmake jq ;; *) - "$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES + "$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" ;; esac } @@ -49,4 +49,4 @@ installDepend() { checkEnv checkAURHelper checkEscalationTool -installDepend \ No newline at end of file +installDepend diff --git a/core/tabs/system-setup/system-cleanup.sh b/core/tabs/system-setup/system-cleanup.sh index dccbcf3a4..70cfd5b6f 100755 --- a/core/tabs/system-setup/system-cleanup.sh +++ b/core/tabs/system-setup/system-cleanup.sh @@ -22,7 +22,7 @@ cleanup_system() { ;; pacman) "$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm - "$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null || true + "$ESCALATION_TOOL" "$PACKAGER" -Rns "$(pacman -Qtdq)" --noconfirm > /dev/null || true ;; apk) "$ESCALATION_TOOL" "$PACKAGER" cache clean diff --git a/core/tabs/utils/bluetooth-control.sh b/core/tabs/utils/bluetooth-control.sh index 6bfe266ba..f18a32a10 100644 --- a/core/tabs/utils/bluetooth-control.sh +++ b/core/tabs/utils/bluetooth-control.sh @@ -65,12 +65,11 @@ scan_devices() { printf "%b\n" "$devices" fi printf "%b" "Press any key to return to the main menu..." - read -r dummy + read -r _ } # Function to prompt for MAC address using numbers prompt_for_mac() { - action=$1 command=$2 prompt_msg=$3 success_msg=$4 @@ -82,14 +81,14 @@ prompt_for_mac() { if [ -z "$devices" ]; then printf "%b\n" "${RED}No devices available. Please scan for devices first.${RC}" printf "%b" "Press any key to return to the main menu..." - read -r dummy + read -r _ return fi # Display devices with numbers device_list=$(echo "$devices" | tr '\n' '\n') i=1 - echo "$device_list" | while IFS= read -r device; do + for device in $device_list; do printf "%d. %s\n" "$i" "$device" i=$((i + 1)) done @@ -102,12 +101,12 @@ prompt_for_mac() { device=$(echo "$device_list" | sed -n "${choice}p") mac=$(echo "$device" | awk '{print $2}') if bluetoothctl info "$mac" > /dev/null 2>&1; then - bluetoothctl "$command" "$mac" && { + if bluetoothctl "$command" "$mac"; then printf "%b\n" "${GREEN}$success_msg${RC}" break - } || { + else printf "%b\n" "${RED}$failure_msg${RC}" - } + fi else printf "%b\n" "${RED}Invalid MAC address. Please try again.${RC}" fi @@ -118,7 +117,7 @@ prompt_for_mac() { fi done printf "%b" "Press any key to return to the main menu..." - read -r dummy + read -r _ } # Function to pair with a device diff --git a/core/tabs/utils/encrypt_decrypt_tool.sh b/core/tabs/utils/encrypt_decrypt_tool.sh index 40e006a25..80e8bbc83 100644 --- a/core/tabs/utils/encrypt_decrypt_tool.sh +++ b/core/tabs/utils/encrypt_decrypt_tool.sh @@ -62,11 +62,11 @@ encrypt_file() { if [ -d "$INPUT_PATH" ]; then # Encrypt each file in the directory find "$INPUT_PATH" -type f | while read -r FILE; do - REL_PATH="${FILE#$INPUT_PATH/}" + REL_PATH="${FILE#"$INPUT_PATH"/}" OUTPUT_FILE="$OUTPUT_PATH/$REL_PATH.enc" mkdir -p "$(dirname "$OUTPUT_FILE")" - openssl enc -aes-256-cbc -salt -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD" - if [ $? -eq 0 ]; then + + if [ "$(openssl enc -aes-256-cbc -salt -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD")" -eq 0 ]; then printf "%b\n" "Encrypted: $OUTPUT_FILE" else printf "%b\n" "Failed to encrypt: $FILE" @@ -79,8 +79,8 @@ encrypt_file() { return fi mkdir -p "$(dirname "$OUTPUT_PATH")" - openssl enc -aes-256-cbc -salt -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD" - if [ $? -eq 0 ]; then + + if [ "$(openssl enc -aes-256-cbc -salt -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD")" -eq 0 ]; then printf "%b\n" "Encrypted: $OUTPUT_PATH" else printf "%b\n" "Failed to encrypt: $INPUT_PATH" @@ -107,11 +107,11 @@ decrypt_file() { if [ -d "$INPUT_PATH" ]; then # Decrypt each file in the directory find "$INPUT_PATH" -type f -name '*.enc' | while read -r FILE; do - REL_PATH="${FILE#$INPUT_PATH/}" + REL_PATH="${FILE#"$INPUT_PATH"/}" OUTPUT_FILE="$OUTPUT_PATH/${REL_PATH%.enc}" mkdir -p "$(dirname "$OUTPUT_FILE")" - openssl enc -aes-256-cbc -d -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD" - if [ $? -eq 0 ]; then + + if [ "$(openssl enc -aes-256-cbc -d -pbkdf2 -in "$FILE" -out "$OUTPUT_FILE" -k "$PASSWORD")" -eq 0 ]; then printf "%b\n" "Decrypted: $OUTPUT_FILE" else printf "%b\n" "Failed to decrypt: $FILE" @@ -124,8 +124,8 @@ decrypt_file() { return fi mkdir -p "$(dirname "$OUTPUT_PATH")" - openssl enc -aes-256-cbc -d -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD" - if [ $? -eq 0 ]; then + + if [ "$(openssl enc -aes-256-cbc -d -pbkdf2 -in "$INPUT_PATH" -out "$OUTPUT_PATH" -k "$PASSWORD")" -eq 0 ]; then printf "%b\n" "Decrypted: $OUTPUT_PATH" else printf "%b\n" "Failed to decrypt: $INPUT_PATH" @@ -148,10 +148,10 @@ main(){ esac printf "%b\n" "Press [Enter] to continue..." - read -r dummy + read -r _ done } checkEnv checkEscalationTool -main \ No newline at end of file +main diff --git a/core/tabs/utils/monitor-control/set_brightness.sh b/core/tabs/utils/monitor-control/set_brightness.sh index 0b7a2a838..ce77e35be 100755 --- a/core/tabs/utils/monitor-control/set_brightness.sh +++ b/core/tabs/utils/monitor-control/set_brightness.sh @@ -29,7 +29,7 @@ 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 -r dummy + read -r _ continue fi @@ -37,7 +37,7 @@ adjust_monitor_brightness() { if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$monitor_count" ]; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" printf "Press [Enter] to continue..." - read -r dummy + read -r _ continue fi diff --git a/core/tabs/utils/monitor-control/set_resolutions.sh b/core/tabs/utils/monitor-control/set_resolutions.sh index 84aea4d5a..9dbb7eaff 100755 --- a/core/tabs/utils/monitor-control/set_resolutions.sh +++ b/core/tabs/utils/monitor-control/set_resolutions.sh @@ -33,7 +33,7 @@ set_resolutions() { if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then printf "%b\n" "${RED}Invalid selection. Please try again.${RC}" printf "%b\n" "Press [Enter] to continue..." - read -r dummy + read -r _ continue fi diff --git a/core/tabs/utils/ollama.sh b/core/tabs/utils/ollama.sh index 5552c4f93..47f995394 100644 --- a/core/tabs/utils/ollama.sh +++ b/core/tabs/utils/ollama.sh @@ -85,7 +85,8 @@ run_model() { printf "%b\n" "${installed_models}" printf "%b\n" "${YELLOW}Custom Models${RC}" - custom_models=$(ollama list | grep 'custom-model-prefix') + custom_models=$(ollama list | grep 'custom-model-prefix') + printf "%b\n" "${custom_models}" printf "%b" "Select a model to run: " printf "%b" "Enter the number corresponding to the model or enter the name of a custom model: " @@ -195,7 +196,7 @@ menu() { esac printf "%b\n" "${YELLOW}Press Enter to continue...${RC}" - read -r dummy + read -r _ done } diff --git a/core/tabs/utils/samba-ssh-setup.sh b/core/tabs/utils/samba-ssh-setup.sh index aa0dc30ea..2de1bf7dc 100755 --- a/core/tabs/utils/samba-ssh-setup.sh +++ b/core/tabs/utils/samba-ssh-setup.sh @@ -173,7 +173,7 @@ setup_ssh_samba(){ printf "%b\n" "5. Exit" printf "%b" "Enter your choice (1-5): " - read CHOICE + read -r CHOICE case "$CHOICE" in 1) @@ -205,4 +205,4 @@ setup_ssh_samba(){ checkEnv checkEscalationTool -setup_ssh_samba \ No newline at end of file +setup_ssh_samba diff --git a/core/tabs/utils/service-control.sh b/core/tabs/utils/service-control.sh index 903fa826d..ea51089f7 100644 --- a/core/tabs/utils/service-control.sh +++ b/core/tabs/utils/service-control.sh @@ -267,10 +267,10 @@ main() { esac printf "%b\n" "Press [Enter] to continue..." - read -r dummy + read -r _ done } checkEnv checkEscalationTool -main \ No newline at end of file +main diff --git a/core/tabs/utils/ssh.sh b/core/tabs/utils/ssh.sh index e5a899ef6..f73c4c18c 100644 --- a/core/tabs/utils/ssh.sh +++ b/core/tabs/utils/ssh.sh @@ -250,4 +250,4 @@ done checkEnv checkEscalationTool -main \ No newline at end of file +main diff --git a/core/tabs/utils/timeshift.sh b/core/tabs/utils/timeshift.sh index b38483e5c..3b932c25c 100644 --- a/core/tabs/utils/timeshift.sh +++ b/core/tabs/utils/timeshift.sh @@ -67,6 +67,7 @@ create_snapshot() { "$ESCALATION_TOOL" timeshift --create --comments "$COMMENT" --tags "$TAG" fi + # shellcheck disable=SC2181 if [ $? -eq 0 ]; then printf "%b\n" "${GREEN}Snapshot created successfully.${RC}" else @@ -93,6 +94,7 @@ restore_snapshot() { "$ESCALATION_TOOL" timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes fi + # shellcheck disable=SC2181 if [ $? -eq 0 ]; then printf "%b\n" "${GREEN}Snapshot restored successfully.${RC}" else @@ -110,6 +112,7 @@ delete_snapshot() { printf "%b\n" "${YELLOW}Deleting snapshot $SNAPSHOT...${RC}" "$ESCALATION_TOOL" timeshift --delete --snapshot "$SNAPSHOT" --yes + # shellcheck disable=SC2181 if [ $? -eq 0 ]; then printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}" else @@ -126,6 +129,7 @@ delete_all_snapshots() { if [ "$CONFIRMATION" = "y" ] || [ "$CONFIRMATION" = "Y" ]; then printf "%b\n" "${CYAN}Deleting all snapshots...${RC}" "$ESCALATION_TOOL" timeshift --delete-all --yes + # shellcheck disable=SC2181 if [ $? -eq 0 ]; then printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}" else @@ -153,7 +157,7 @@ main_menu() { *) printf "%b\n" "${RED}Invalid option. Please try again.${RC}" ;; esac printf "%b\n" "${CYAN}Press Enter to continue...${RC}" - read -r dummy + read -r _ done } diff --git a/core/tabs/utils/user-account-manager/add_to_group.sh b/core/tabs/utils/user-account-manager/add_to_group.sh index 665cf72ac..077205056 100755 --- a/core/tabs/utils/user-account-manager/add_to_group.sh +++ b/core/tabs/utils/user-account-manager/add_to_group.sh @@ -33,7 +33,7 @@ addToGroup() { groups_to_add=$(echo "$groups" | tr ' ' ',') printf "%b" "${YELLOW}Are you sure you want to add user $username to $groups_to_add? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 "$ESCALATION_TOOL" usermod -aG "$groups_to_add" "$username" @@ -44,4 +44,4 @@ addToGroup() { checkEnv checkEscalationTool checkGroups -addToGroup \ No newline at end of file +addToGroup diff --git a/core/tabs/utils/user-account-manager/change_password.sh b/core/tabs/utils/user-account-manager/change_password.sh index a909a5b2b..20706bd3e 100755 --- a/core/tabs/utils/user-account-manager/change_password.sh +++ b/core/tabs/utils/user-account-manager/change_password.sh @@ -17,7 +17,7 @@ changePassword() { read -r password printf "%b" "${YELLOW}Are you sure you want to change password for ""$username""? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 echo "$username:$password" | "$ESCALATION_TOOL" chpasswd @@ -30,4 +30,4 @@ changePassword() { checkEnv checkEscalationTool -changePassword \ No newline at end of file +changePassword diff --git a/core/tabs/utils/user-account-manager/delete_user.sh b/core/tabs/utils/user-account-manager/delete_user.sh index aee9482e3..f4795872a 100755 --- a/core/tabs/utils/user-account-manager/delete_user.sh +++ b/core/tabs/utils/user-account-manager/delete_user.sh @@ -14,7 +14,7 @@ deleteUser() { if id "$username" > /dev/null 2>&1; then printf "%b" "${YELLOW}Are you sure you want to delete user ""$username""? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 $ESCALATION_TOOL userdel --remove "$username" 2>/dev/null @@ -27,4 +27,4 @@ deleteUser() { checkEnv checkEscalationTool -deleteUser \ No newline at end of file +deleteUser diff --git a/core/tabs/utils/user-account-manager/remove_from_group.sh b/core/tabs/utils/user-account-manager/remove_from_group.sh index 23935b5e4..1c07b0063 100755 --- a/core/tabs/utils/user-account-manager/remove_from_group.sh +++ b/core/tabs/utils/user-account-manager/remove_from_group.sh @@ -34,14 +34,14 @@ removeFromGroup() { groups_to_remove=$(echo "$groups" | tr ' ' ',') printf "%b" "${YELLOW}Are you sure you want to remove user $username from $groups_to_remove? [Y/n]: ${RC}" - read -r confirm + read -r _ confirmAction || exit 1 - $ESCALATION_TOOL usermod -rG $groups_to_remove "$username" + $ESCALATION_TOOL usermod -rG "$groups_to_remove" "$username" printf "%b\n" "${GREEN}User successfully removed from $groups_to_remove${RC}" } checkEnv checkEscalationTool -removeFromGroup \ No newline at end of file +removeFromGroup diff --git a/core/tabs/utils/utility_functions.sh b/core/tabs/utils/utility_functions.sh index 09f33c60a..acadee682 100755 --- a/core/tabs/utils/utility_functions.sh +++ b/core/tabs/utils/utility_functions.sh @@ -30,6 +30,7 @@ execute_command() { command="$1" printf "Executing: %s\n" "$command" eval "$command" 2>&1 | tee /tmp/xrandr.log | tail -n 20 + # shellcheck disable=SC2181 if [ $? -ne 0 ]; then printf "%b\n" "${RED}An error occurred while executing the command. Check /tmp/xrandr.log for details.${RC}" fi diff --git a/core/tabs/utils/wifi-control.sh b/core/tabs/utils/wifi-control.sh index d4ed2d10b..0a8f05153 100755 --- a/core/tabs/utils/wifi-control.sh +++ b/core/tabs/utils/wifi-control.sh @@ -75,33 +75,33 @@ scan_networks() { echo "$networks" | awk -F: '{printf("%d. SSID: %-25s \n", NR, $1)}' fi printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ } # Function to turn WiFi on wifi_on() { clear printf "%b\n" "${YELLOW}Turning WiFi on...${RC}" - nmcli radio wifi on && { + if "$(nmcli radio wifi on)"; then printf "%b\n" "${GREEN}WiFi is now turned on.${RC}" - } || { + else printf "%b\n" "${RED}Failed to turn on WiFi.${RC}" - } + fi printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ } # Function to turn WiFi off wifi_off() { clear printf "%b\n" "${YELLOW}Turning WiFi off...${RC}" - nmcli radio wifi off && { + if "$(nmcli radio wifi off)"; then printf "%b\n" "${GREEN}WiFi is now turned off.${RC}" - } || { + else printf "%b\n" "${RED}Failed to turn off WiFi.${RC}" - } + fi printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ } # Function to prompt for WiFi network selection @@ -118,7 +118,7 @@ prompt_for_network() { if [ -z "$networks" ]; then printf "%b\n" "${RED}No networks available. Please scan for networks first.${RC}" printf "%b\n" "Press any key to return to the main menu..." - read -r dummy + read -r _ rm -f "$temp_file" return fi @@ -142,18 +142,18 @@ prompt_for_network() { printf "%b" "Enter password for SSID: " "$ssid" read -r password printf "\n" - nmcli dev wifi connect "$ssid" password "$password" && { + if "$(nmcli dev wifi connect "$ssid" password "$password")"; then printf "%b\n" "${GREEN}$success_msg${RC}" - } || { + else printf "%b\n" "${RED}$failure_msg${RC}" - } + fi fi else printf "%b\n" "${RED}Invalid choice. Please try again.${RC}" fi printf "%b\n" "Press any key to return to the selection menu..." - read -r dummy + read -r _ done rm -f "$temp_file" @@ -178,4 +178,4 @@ remove_network() { checkEnv checkEscalationTool setupNetworkManager -main_menu \ No newline at end of file +main_menu