From b46569c38ba387f31cb555d653c3aef21d21684b Mon Sep 17 00:00:00 2001 From: Mayur Raut <95993675+RazoBeckett@users.noreply.github.com> Date: Sun, 15 Sep 2024 19:04:39 +0530 Subject: [PATCH] feat(dwmtitus-setup): improve slstatus installation using loop --- tabs/applications-setup/dwmtitus-setup.sh | 45 ++++++++++++----------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/tabs/applications-setup/dwmtitus-setup.sh b/tabs/applications-setup/dwmtitus-setup.sh index 743c8781..961e8892 100755 --- a/tabs/applications-setup/dwmtitus-setup.sh +++ b/tabs/applications-setup/dwmtitus-setup.sh @@ -296,27 +296,30 @@ setupDisplayManager() { } install_slstatus() { - printf "Do you want to install slstatus? (y/n): " # using printf instead of 'echo' to avoid newline, -n flag for 'echo' is not supported in POSIX - read -r response # -r flag to prevent backslashes from being interpreted - case "$response" in - [Yy] | [Yy][Ee][Ss]) # Matches: Y, y, Yes, yes, YES, yEs, yeS, etc. - echo "Installing slstatus" - cd slstatus/ || { echo "Failed to change directory to slstatus"; return 1; } - if $ESCALATION_TOOL make clean install; then - echo "slstatus installed successfully" - else - echo "Failed to install slstatus" - return 1 - fi - ;; - [Nn] | [Nn][Oo]) # same logic as above, but for No - echo "Skipping slstatus installation" - ;; - *) - echo "Invalid input. Please enter y/yes or n/no." - install_slstatus - ;; - esac + while true; do + printf "Do you want to install slstatus? (y/n): " # using printf instead of 'echo' to avoid newline, -n flag for 'echo' is not supported in POSIX + read -r response # -r flag to prevent backslashes from being interpreted + case "$response" in + [Yy] | [Yy][Ee][Ss]) # Matches: Y, y, Yes, yes, YES, yEs, yeS, etc. + echo "Installing slstatus" + cd slstatus/ || { echo "Failed to change directory to slstatus"; return 1; } + if $ESCALATION_TOOL make clean install; then + echo "slstatus installed successfully" + else + echo "Failed to install slstatus" + return 1 + fi + break + ;; + [Nn] | [Nn][Oo]) # same logic as above, but for No + echo "Skipping slstatus installation" + break + ;; + *) + echo "Invalid input. Please enter y/yes or n/no." + ;; + esac + done cd .. }