I'm building a sitemap from mysql and to speed things-up I would like to send my function to the background. When I do so, the "$SITEMAP" variable appears empty.
what I've tried is setting export SITEMAP="$SITEMAP"
for ((i=0; i<CNT; i++)); do
    xml() {
        ...
        export SITEMAP="$SITEMAP"
    }
    xml &
    echo -e "$SITEMAP"
done
ps: without sending to background the "xml" function, script works correctly.
 
     
     
     
    