First my sourcecode to test the returning method of bash functions:
function oidev.fnc.bash.example.fncreturnstringvalue
{
echo "ABC"
return 1
}
and the caller function:
function oidev.fnc.bash.example.fncreturnstringvaluecaller
{
local FNCVALUE
local FNCSTRING
FNCSTRING=$(oidev.fnc.bash.example.fncreturnstringvalue && FNCVALUE="$?" || FNCVALUE="$?")
# String OK but Value empty
echo "VALUE : $FNCVALUE"
echo "STRING: $FNCSTRING"
unset FNCVALUE
unset FNCSTRING
oidev.fnc.bash.example.fncreturnstringvalue && FNCVALUE="$?" || FNCVALUE="$?"
# Value OK and String on STDOUT
echo "VALUE : $FNCVALUE"
echo "STRING: $FNCSTRING"
}
The output in bash:
VALUE :
STRING: ABC
ABC
VALUE : 1
STRING: (surely empty, but echoed from the function)
`
And now my simple question:
Is it possible to get the returning string and returning value into two different variables by a single line construction?
I don't want to use globals, nore the use of if $? after the sub-call!
Many thanks for help, and sorry for my german-english!