Sorry if I am not clear...
I suppose it is how you look at a problem. And once understood, try to figure out how to fix it. I guess bash script experience helps.
Because you know what works or not.
Lets take an example, here is a script :
Code:
function A
{
echo 'I am function A'
}
function B
{
echo 'I am function B, I am calling function A'
RA=$(A)
}
echo 'I am main, I am calling function B'
B
If you run it, it returns :
Quote:
I am main, I am calling function B
I am function B, I am calling function A
|
A and B are both functions, we can see B's echo and not A's echo.
This was your problem, as simple as it is when you throw away everything else.
So what is the difference ? The ways A and B are called.
Calling A in a subshell :
and everything that A echoes (on the standard output) is into RA.
Add :
at the end of B function, it returns :
Quote:
I am main, I am calling function B
I am function B, I am calling function A
RA = I am function A
|
So we understand the problem. And thanks to my bash script experience, I know that RA store every A's echoes. So I did not need to try it.
Now how to fix it ? I guess there is several ways.
You can probably play with standard and error outputs. But the main idea for me was to call A as B, meaning outside of a subshell.
But doing this means to find a new way to get the result of A, what we really want.
'return' can not be apply because it has to be integer.
So, it was using either global variable, either parameter's function by reference. Both works. I just went with the sexier.