JaKooLit / Arch-Hyprland

For automated installation of Hyprland on Arch or any arch based distros
GNU General Public License v3.0
1.35k stars 109 forks source link

fix: fix infinte loop when prompting for SDDM themes #41

Closed cbaconnier closed 6 months ago

cbaconnier commented 6 months ago

Pull Request

Description

As I was running the script on my VM, I hit x instead of y and got stuck in an infinite loop. Resetting the prompt variable (install_sddm_theme) fix the issue. I haven't checked if the issue was present elsewhere in the scripts.

Type of change

Please put an x in the boxes that apply:

Checklist

Please put an x in the boxes that apply:

Additional context

Tested locally with a minimal reproducible example


# SDDM-themes
valid_input=false
while [ "$valid_input" != true ]; do
  if [[ -z $install_sddm_theme ]]; then
    read -n 1 -r -p "OPTIONAL - Would you like to install SDDM themes? (y/n)" install_sddm_theme
  fi
  if [[ $install_sddm_theme =~ ^[Yy]$ ]]; then
    printf "\n%s - Installing Simple SDDM Theme\n"
    valid_input=true
  elif [[ $install_sddm_theme =~ ^[Nn]$ ]]; then
    printf "\n%s - No SDDM themes will be installed.\n"
    valid_input=true
  else
    printf "\n%s - Invalid input. Please enter 'y' for Yes or 'n' for No.\n"
    # uncomment for the fix
    # install_sddm_theme=""
  fi
done
JaKooLit commented 6 months ago

its written there.... type y or n NOT x

and yes it will loop since it will only accept either Y y or N n

cbaconnier commented 6 months ago

@JaKooLit I agree, it should only accept Yy/Nn but we shouldn't be stuck in a infinite loop. Currently the only way is to type Ctrl+c and quit the script.

I pressed x because a mistyped. (On my keyboard it next to y)

Even better, if [[ -z $install_sddm_theme ]]; then could be removed, resetting the variable shouldn't be necessary afterward.

https://github.com/JaKooLit/Arch-Hyprland/assets/4738184/228e8ef7-a23d-418f-a02e-9435c9503664

JaKooLit commented 6 months ago

what happen if you press n?

cbaconnier commented 6 months ago

what happen if you press n?

Nothing, it keep going

JaKooLit commented 6 months ago

hmmmm weird....

I just tried now, choosing n will just skip installing sddm

can you attach here the sddm log?

cbaconnier commented 6 months ago

Sure!

To be sure we are on the same page:

what happen if you press n?

--

After the first loop : install_sddm_theme will still contains x so this condition if [[ -z $install_sddm_theme ]]; will be false (since the variable is not empty) and we won't have a chance to be re-prompting OPTIONAL - Would you like to install SDDM themes? (y/n) to the user.

Therefore, install_sddm_theme will never change and we will go down to the last else condition, resulting in a loop.

install-07-202805_sddm.log

JaKooLit commented 6 months ago

Oh my bad... and you were right...

I just reviewed again... thanks alot

however, in the future, kindly make a PR on the development branch.

thanks alot

cbaconnier commented 6 months ago

No problem, I will do!

Have a great day / evening and thanks for what you do for the community. Much appreciated ! :heart: