Last active
October 24, 2023 15:54
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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