fix(installer): correct check for `sudo` in shell change logic
Diff
1diff --git a/tools/install.sh b/tools/install.sh
2index 9ad6f7d140549a38dbab9a52abb6ac87c5f869ed..34dca841373832d96b6079ee540faa415c7fec90 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -60,6 +60,8 @@ command_exists() {
6 }
7 8 user_can_sudo() {
9+ # Check if sudo is installed
10+ command_exists sudo || return 1
11 # The following command has 3 parts:
12 #
13 # 1. Run `sudo` with `-v`. Does the following:
14@@ -78,7 +80,7 @@ user_can_sudo() {
15 # to run `sudo` in the default locale (with `LANG=`) so that the message
16 # stays consistent regardless of the user's locale.
17 #
18- LANG= sudo -n -v 2>&1 | grep -q "may not run sudo"
19+ ! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo"
20 }
2122 # The [ -t 1 ] check only works when the function is not called from
23@@ -395,9 +397,9 @@ EOF
24 # be prompted for the password either way, so this shouldn't cause any issues.
25 #
26 if user_can_sudo; then
27- chsh -s "$zsh" "$USER" # run chsh normally
28- else
29 sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt
30+ else
31+ chsh -s "$zsh" "$USER" # run chsh normally
32 fi
3334 # Check if the shell change was successful