mac osx

Install bash again in your Mac osx, why?

gimslab.com 2021. 8. 1. 13:34

It's a very outdated version of the Bash shell on Mac OSX. maybe like GNU bash, version 3.2

I needed full features of a recent version of bash. There are many exceptions in an old version of bash like this.

$ printf %d "'가'"  
-22

so just I did this to version up.

$ brew install bash

and I can get the below version

$ bash --version  
GNU bash, 버전 5.1.4(1)-release (x86\_64-apple-darwin19.6.0)  
Copyright (C) 2020 Free Software Foundation, Inc.  
라이선스 GPLv3+: GNU GPL version 3 or later <http://gnu.org/license/gpl.html>  

This is free software; you are free to change and redistribute it.  
There is NO WARRANTY, to the extent permitted by law.

I have two versions of bash from now.

$ which -a bash
/usr/local/bin/bash
/bin/bash

new one and the old one

add new bash to the whitelist shell file /etc/shells like below

% cat /etc/shells
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/bash

set it as a default set

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

Good! I can get this same result with my other bash in Linux.

$ printf %d "'가'"
44032