Bash allows returning status codes (integers) from functions; however, how can a string be returned?
Returning a string from a function
In Bash, command substitution can be used to capture the stdout of a function.
|
|
Output
|
|
Returning a string and status from a function
If the standard output and status code need capturing, the example above can be modified to include a return status.
|
|
Output
|
|