Skip to content

Instantly share code, notes, and snippets.

@ariesmcrae
Created October 24, 2024 10:40
Show Gist options
  • Save ariesmcrae/8d7443e276d2ab90818a334da064e443 to your computer and use it in GitHub Desktop.
Save ariesmcrae/8d7443e276d2ab90818a334da064e443 to your computer and use it in GitHub Desktop.
Upgrade Apple Silicon macOS Bash from v3.x to 5.x

Find out which Bash version you're currently using

# check current Bash version
bash -version

# output:
# GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)
# locate current Bash
which -a bash

# output
/bin/bash

Upgrade your Bash version to 5.x or above

brew install bash 
# locate bash installations
which -a bash

# output
/opt/homebrew/bin//bash
/opt/homebrew/bin/bash
/bin/bash
# put this near the top of your `/.zshrc` to ensure this is the first PATH that is declared
export PATH="/opt/homebrew/bin/:$PATH"
# check new Bash version
bash -version

# output:
# GNU bash, version 5.2.37(1)-release (aarch64-apple-darwin23.4.0)

When writing a Bash file

# ensure you use this
#!/usr/bin/env bash

# Don't use this. It's not portable across different machines
#!/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment