I want to use a variable initialized into a subscript, in order to avoid returning it with echo
or return
.
For example, my goal is to output $myvar with this script:
eval "./script.sh"
echo -n $myvar
declared inside script.sh like this:
declare -gx myvar # global and exported var
myvar=42
Output:
nothing
Is there another command or flag to add in replacement to declare -gx
? Or moving it before eval
is the solution ?