If in my automation script, I need to do something like install oh-my-zsh, I will have a .sh script like this:
#!/bin/sh
runuser -l user -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"'
This works and will install oh-my-zsh as I expect but it then puts the session into a zsh shell. If I add the command exit
to the end of the script, it does nothing.
How can I either disallow switching to zsh (Or any other shell) or exit from it in my script?
If you actually look at this script you will see that, as the last thing it does, it calls:
Just before that, you will see that it checks to see if the
RUNZSH
variable is set tono
. If so, then it will simply exit without going into the shell.So all you need to do is pass the environment variable
RUNZSH=no
to the command.The comments at the top of the script contain other variables you can set and command line options you can use.