created on | January 18, 2022 |
a shell script function can’t return anything else apart from an exit status, that is, an integer value. but there are workarounds for returning others values like strings.
function:
invocation:
function:
invocation:
the problem with this workaround is that anything that gets spit out to stdout and stderr end ups in ‘somevar’. you might need to set stderr to an other output channel like /dev/null.
the shared variable has to be declared before the declaration of the function.
shared variable and function:
invocation: