Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
788802af
Unverified
Commit
788802af
authored
Jan 24, 2022
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(installer): correct check for `sudo` in shell change logic
parent
861805b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
install.sh
tools/install.sh
+5
-3
No files found.
tools/install.sh
View file @
788802af
...
@@ -60,6 +60,8 @@ command_exists() {
...
@@ -60,6 +60,8 @@ command_exists() {
}
}
user_can_sudo
()
{
user_can_sudo
()
{
# Check if sudo is installed
command_exists
sudo
||
return
1
# The following command has 3 parts:
# The following command has 3 parts:
#
#
# 1. Run `sudo` with `-v`. Does the following:
# 1. Run `sudo` with `-v`. Does the following:
...
@@ -78,7 +80,7 @@ user_can_sudo() {
...
@@ -78,7 +80,7 @@ user_can_sudo() {
# to run `sudo` in the default locale (with `LANG=`) so that the message
# to run `sudo` in the default locale (with `LANG=`) so that the message
# stays consistent regardless of the user's locale.
# 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
# The [ -t 1 ] check only works when the function is not called from
...
@@ -395,9 +397,9 @@ EOF
...
@@ -395,9 +397,9 @@ EOF
# be prompted for the password either way, so this shouldn't cause any issues.
# be prompted for the password either way, so this shouldn't cause any issues.
#
#
if
user_can_sudo
;
then
if
user_can_sudo
;
then
chsh
-s
"
$zsh
"
"
$USER
"
# run chsh normally
else
sudo
-k
chsh
-s
"
$zsh
"
"
$USER
"
# -k forces the password prompt
sudo
-k
chsh
-s
"
$zsh
"
"
$USER
"
# -k forces the password prompt
else
chsh
-s
"
$zsh
"
"
$USER
"
# run chsh normally
fi
fi
# Check if the shell change was successful
# Check if the shell change was successful
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment