For information on how to install MacPorts see here and here.
export PATH="/opt/local/bin:/opt/local/sbin:/opt/local/lib:/opt/local/include:/opt/local/man:/usr/bin:/bin:/usr/sbin:/sbin" export IFS=$' \t\n' 1. /opt/local/bin/port info bash /usr/bin/sudo /opt/local/bin/port -c install bash 2. # add '/opt/local/bin/bash' to /private/etc/shells /usr/bin/sudo /usr/bin/nano /private/etc/shells 3. # enable UTF-8 support by adding to your ~/.bash_login (or alternatives): # /usr/bin/locale -a export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 4. man chsh # run chsh and change the path of the shell to /opt/local/bin/bash chsh 5. # set encoding of Terminal.app to UTF-8 /usr/bin/defaults read com.apple.Terminal StringEncoding /usr/bin/defaults write com.apple.Terminal StringEncoding -int 4 /usr/bin/defaults read com.apple.Terminal DoubleWideChars /usr/bin/defaults write com.apple.Terminal DoubleWideChars -bool YES kill -HUP $$ #killall -HUP Terminal 6. # [cmd-,] Terminal -> Preferences... -> select: Execute this command (specify complete path): /opt/local/bin/bash #--------------------------------------------------------------------------- # Bash 3.0 Announcement # http://groups.google.com/group/gnu.announce/msg/e05c4cbeecdb24c7 # http://en.opensuse.org/Bash bash --version which bash dscl . read /Users/$(/usr/bin/logname) UserShell man 7 re_format # POSIX 1003.2 regular expressions man /opt/local/share/man/man1/bash.1.gz 2>/dev/null | less -p '=~' man /opt/local/share/man/man1/bash.1.gz 2>/dev/null | less -p regex # new feature of Bash 3.0 ff.: in-process regular expression matching str='abc def' if [[ "${str}" =~ 'c d' ]]; then printf "%s\n" "${BASH_REMATCH[0]}"; fi printf "%s\n" "${BASH_REMATCH[0]}" printf "%s\n" "${#BASH_REMATCH[*]}" printf "%s\n" "${#BASH_REMATCH[@]}"