Skip to content

Instantly share code, notes, and snippets.

View ariesmcrae's full-sized avatar
💭
typescript, node.js, aws, java, go (golang)

A. M. ariesmcrae

💭
typescript, node.js, aws, java, go (golang)
View GitHub Profile
@ariesmcrae
ariesmcrae / apple-silicon-macOS-Bash-upgrade.md
Created October 24, 2024 10:40
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)
@ariesmcrae
ariesmcrae / bash-method-multiple-return-values.md
Last active October 24, 2024 10:47
Bash v5 scripting: Method returns multiple values
get_person_details() {
    local name="John"
    local age=25

    # Return the values
    echo "$name $age"
}

# Extract the values from the func
@ariesmcrae
ariesmcrae / bash-5-hash-set.md
Last active October 24, 2024 23:03
Bash v5 scripting: Hash Set example
#!/usr/bin/env bash

set -euo pipefail

declare -A hash_set

# Add elements to the hash set
hash_set["name1"]="Matthew"
hash_set["name2"]="Luke"
@ariesmcrae
ariesmcrae / check-bash-version.md
Created October 24, 2024 11:21
Bash v5 scripting: Check Bash version
usr/bin/env bash

set -euo pipefail

check_bash_version() {
    if [[ ${BASH_VERSINFO[0]} -lt 5 ]]; then
        echo "Error: At least Bash version 5 is required."
        echo "Your Bash version is: ${BASH_VERSINFO[0]}"        
 exit 1