I originally coded something to fetch a file via wget
like this:
local wget_output=$(wget -O "${TEMP_FILE}" "$REQUEST_URL" 2>&1)
local wget_success=$?
if [[ $wget_success -eq 0 ]]; then
so that the 'then' clause would only execute if the wget
was successful. However, it executed every time (ie. when the requested file was not on the server.) This code works functionally correct:
wget_output=$(wget -O "${TEMP_FILE}" "$REQUEST_URL" 2>&1)
local wget_success=$?
if [[ $wget_success -eq 0 ]]; then
The only difference is the removal of the first local
. Can anyone explain why?