Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jimratliff/d735a57eef05b650d4a17f10b7da64d9 to your computer and use it in GitHub Desktop.

Select an option

Save jimratliff/d735a57eef05b650d4a17f10b7da64d9 to your computer and use it in GitHub Desktop.
Example: Bash function returns multiple values, passed via command substitution, with a READ command and Here string in calling script #bash #bash_exemplar
# Example: Bash function returns multiple values, passed via command substitution,
# with a READ command and Here string in calling script
#!/usr/bin/env bash
set -e #Stop on any errors
function inside_function() {
yvariable1="8"
yvariable2="64"
echo $yvariable1 $yvariable2
}
read -r ans1 ans2 <<< $(inside_function)
echo "ans1 = $ans1"
echo "ans2 = $ans2"
##########################################################################################
OUTPUT:
ans1 = 8
ans2 = 64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment