I've written a quick-and-dirty script to time some reports from a web service:BASE_URL='http://example.com/json/webservice/'FIRST=1FINAL=10000for report_code in $(seq 1 $FINAL); do  (time -p response=$(curl --write-out %{http_code} --silent -O ${BASE_URL}/${report_code}) ) 2> ${report_code}.time  echo $response  # <------- this is out of scope!  How do I fix that?  if [[ $response = '404' ]]; then    echo Deleting report # ${report_code}!    rm ${report_code}  else    echo ${report_code} seems to be good!  fidoneI need to wrap the time command in a subshell so I can redirect its output, but that makes the value of $response unavailable to the parent shell.  How do I get around this problem?
How to make a variable from a subshell available in the parent shell
bash;shell;io redirection;subshell
You can't bring a variable's value from a subshell to its parent, not without doing some error-prone marshalling and cumbersome communication.Fortunately, you don't need a subshell here. Redirection only requires command grouping with {  }, not a subshell.{ time -p response=$(curl --write-out '%{http_code}' --silent -O ${BASE_URL}/${report_code}); } 2> ${report_code}.time(Don't forget double quotes around variable substitutions.)