why is bash replaced with zsh?

Hello, it says

"The default interactive shell is now zsh.

To update your account to use zsh, please run `chsh -s /bin/zsh`.

For more details, please visit https://support.apple.com/kb/HT208050."

I wanted to know what are the pros and cons of zsh in comparison to bash?

Posted on Oct 11, 2019 6:49 AM

Reply
11 replies

Oct 11, 2019 6:54 AM in response to mikelis

I like zsh better. Unless you have a large library of shell scripts that are dependent on bash features, you shouldn't see any difference.


The current (i.e. updated) version of bash is under the GPLv3 license which is incompatible with Apple's (or any hardware manufacturer's) business model.


zsh is still under the GPLv2 license.


You can still use the old version of bash if you want, or you can install your own current version of bash. You may have to use some type of package manager like HomeBrew.

Oct 11, 2019 7:17 AM in response to mikelis

Apple has shipped the 2007 vintage of Bash v3 and cannot upgrade to Bash 4 due to GPL3 restrictions. For the same reason, Apple is not including any of the GNU software. As Barney pointed out, the homebrew package manager can install Bash4 and that will go into /usr/local/bin. You could also install the GNU Coreutils in the same manner, which I did.


By shifting to Zsh, Apple can keep it version current. Zsh has far more power than Bash 4. By default, Zsh ignores white-space in filenames, so you do not have to quote Zsh variables to avoid Bash white-space issues. Want an absolute path in Zsh, it is simply ${var:a}. Zsh supports globing so you can do directory recursion. It also supports associative arrays, and ton of other stuff.


The Zsh site has a Zsh Manual for Zsh v5.3 which is current. The Zsh user guide however is dated 2003.


Much of the Bash script logic just works with Zsh, but now, when you open the Terminal, your Bash associated dot files do not get run, so your PATH and other shell customizations need to be set up for Zsh in the ~/.zshrc file. Here is what I have done with mine:


# .zshrc
export PATH=".:$HOME/bin:/usr/local/bin:$PATH"
export MANPATH=.:/usr/share/man:$MANPATH
TPUT="/usr/bin/tput"
Bluebld="$(${TPUT} bold; ${TPUT} setaf 63)"
White="$(${TPUT} bold; ${TPUT} setaf 15)"
Green="$(${TPUT} bold; ${TPUT} setaf 42)"
Normal="$(${TPUT} sgr0)"
MyHost="$(networksetup -getcomputername)"
export CLICOLOR=1
export GREP_COLOR='00;38;5;226'
export GREP_OPTIONS='--color=auto --extended-regexp'
export LSCOLORS='gxfxcxdxbxegedabagacad'
PS1="${Green}${MyHost}: %~ %% ${White}"
export EDITOR="/usr/bin/vim"
bindkey -v


That MyHost is because I do not want a hostname assigned by a remote VPN DNS server. The e/grep color is vivid yellow, and the Zsh uses an entirely different PS1 syntax from Bash. Finally, when I press the escape key in a command line, the bindkey -v allows me to use Vim editor syntax when editing the command-line.

Oct 31, 2019 4:53 PM in response to solaris.neon

solaris.neon wrote:

"The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050."
-- HOW TO DISABLE THIS MESSAGE?????


Different question.

export BASH_SILENCE_DEPRECATION_WARNING=1


That and additional details are available from various discussions, including:

https://scriptingosx.com/2019/06/moving-to-zsh/


Oct 31, 2019 6:05 PM in response to MrHoffman

MrHoffman wrote:
export BASH_SILENCE_DEPRECATION_WARNING=1
https://scriptingosx.com/2019/06/moving-to-zsh/

Thank You. Thank You. Thank You!


I do not have anything against zsh, but I work in a cross platform environment with Linux, Solaris, and AIX, and I have a ton of bash based shell scripts.


Yes I know I do not need to run bash to use a bash shell script. After all, I used csh for years, but wrote /bin/sh (and as in pre-POSIX sh) and ksh scripts.


As I switched to bash in 2005 and it is more comfortable using the same shell when ssh'ing Linux, Solaris and AIX platforms.


So I thank you very much for finding the "export BASH_SILENCE_DEPRECATION_WARNING=1" settings.

Oct 31, 2019 6:42 PM in response to MrHoffman

MrHoffman wrote:
Might eventually be headed for the following, if we’re going to be adding our own bash locally:
#!/usr/bin/env bash
Not that I’ve sorted all the links already used in Catalina, either.

Yea, I've been using #!/usr/bin/env bash for a few years now.


This trick has been helpful when platforms such as Solaris and AIX do not ship bash by default, so it is often in an alternate directory. But many of my script have to work cross-platform.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

why is bash replaced with zsh?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.