The Go Blog

shell bash 4 on macos

bantana
15 April 2017

upgrade bash

Use homebrew to upgrade the default bash 3.2 to bash 4.4 on macos.

brew install bash

/usr/local/bin/bash -> ../Cellar/bash/4.4.12/bin/bash

Register the /usr/local/bin/bash to the system shells.

sudo vi /etc/shells

Adding a line.

/usr/local/bin/bash

Change the default terminal shell to /usr/local/bin/bash

sudo chsh -s /usr/local/bin/bash

Restart or press ctrl-n to open a new terminal.

Verify /usr/local/bin/bash install.

echo $BASH_VERSION

RESULT:

4.4.12(1)-release

or

env|grep -i shell

RESULT:

SHELL=/usr/local/bin/bash

bash debugger

brew install bashdb

bash script 基础

文件开头声明bash路径

#!/bin/bash
or
#!/usr/bin/env bash

bash/hello.sh

#!/usr/bin/env bash
echo $BASH_VERSION
echo "hello, bash world!"

RESULT:

4.4.12(1)-release
hello, bash world!

Related articles