diff options
author | Marc Cornellà <hello@mcornella.com> | 2022-01-24 15:45:42 +0100 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2022-01-24 15:56:10 +0100 |
commit | 788802af68af9a1adbfdb678086939c89d79d999 (patch) | |
tree | 8d9613f9e8e299de7dafff1de4d753e4334d5e73 /tools/install.sh | |
parent | 861805b64d4014550808d2db176fa99bc729eebf (diff) | |
download | zsh-788802af68af9a1adbfdb678086939c89d79d999.tar.gz zsh-788802af68af9a1adbfdb678086939c89d79d999.tar.bz2 zsh-788802af68af9a1adbfdb678086939c89d79d999.zip |
fix(installer): correct check for `sudo` in shell change logic
Diffstat (limited to 'tools/install.sh')
-rwxr-xr-x | tools/install.sh | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/install.sh b/tools/install.sh index 9ad6f7d14..34dca8413 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -60,6 +60,8 @@ command_exists() { } user_can_sudo() { + # Check if sudo is installed + command_exists sudo || return 1 # The following command has 3 parts: # # 1. Run `sudo` with `-v`. Does the following: @@ -78,7 +80,7 @@ user_can_sudo() { # to run `sudo` in the default locale (with `LANG=`) so that the message # stays consistent regardless of the user's locale. # - LANG= sudo -n -v 2>&1 | grep -q "may not run sudo" + ! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo" } # The [ -t 1 ] check only works when the function is not called from @@ -395,9 +397,9 @@ EOF # be prompted for the password either way, so this shouldn't cause any issues. # if user_can_sudo; then - chsh -s "$zsh" "$USER" # run chsh normally - else sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt + else + chsh -s "$zsh" "$USER" # run chsh normally fi # Check if the shell change was successful |