Skip to content

Instantly share code, notes, and snippets.

@ariesmcrae
Last active October 24, 2024 10:47
Show Gist options
  • Save ariesmcrae/fb2e6d0d95120c7a31c6a42b5a8995ab to your computer and use it in GitHub Desktop.
Save ariesmcrae/fb2e6d0d95120c7a31c6a42b5a8995ab to your computer and use it in GitHub Desktop.
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
read -r name age <<< "$(get_person_details)"

echo "Name: $name"
echo "Age: $age"

# output:
Name: John
Age: 25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment