mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
Fix(adduser): better returning to shell of original user
This commit is contained in:
parent
70edfaf348
commit
f26b428f8e
1 changed files with 2 additions and 3 deletions
|
@ -19,18 +19,17 @@ adduser() {
|
||||||
#and also make sure that after the install script we are no longer the new user
|
#and also make sure that after the install script we are no longer the new user
|
||||||
temp_installscript=$(mktemp)
|
temp_installscript=$(mktemp)
|
||||||
cat $path_installscript | \
|
cat $path_installscript | \
|
||||||
sed 's/exec zsh -l//' |
|
|
||||||
sed 's/read -r opt/opt=y; echo "\n--- This time I am answering \\"yes\\" for you, but you will still have to type in the password of that user ---"/' \
|
sed 's/read -r opt/opt=y; echo "\n--- This time I am answering \\"yes\\" for you, but you will still have to type in the password of that user ---"/' \
|
||||||
> $temp_installscript
|
> $temp_installscript
|
||||||
chown ${@[$#]} $temp_installscript && chmod +x $temp_installscript
|
chown ${@[$#]} $temp_installscript && chmod +x $temp_installscript
|
||||||
|
|
||||||
#try installing with sudo or su when not available
|
#try installing with sudo or su when not available
|
||||||
if [[ -x "$commands[sudo]" ]] ; then
|
if [[ -x "$commands[sudo]" ]] ; then
|
||||||
sudo -u ${@[$#]} $temp_installscript
|
sudo -u ${@[$#]} RUNZSH=no $temp_installscript
|
||||||
returncode=$?
|
returncode=$?
|
||||||
else
|
else
|
||||||
if [[ -x "$commands[su]" ]] ; then
|
if [[ -x "$commands[su]" ]] ; then
|
||||||
su -l ${@[$#]} -c $temp_installscript
|
su -l ${@[$#]} -c "$temp_installscript --unattended"
|
||||||
returncode=$?
|
returncode=$?
|
||||||
else
|
else
|
||||||
echo "You can't become ${@[$#]} (no 'sudo' or 'su' available)" > /dev/stderr;
|
echo "You can't become ${@[$#]} (no 'sudo' or 'su' available)" > /dev/stderr;
|
||||||
|
|
Loading…
Reference in a new issue