Is there an elegant way to store and evaluate return values in bash scripts?
The simple solution: output=$(complex_command) status=$? if (( status == 0 )); then : stuff with “$output” fi : more code if (( status == 0 )); then : stuff with “$output” fi Or more eleganter-ish do_complex_command () { # side effects: global variables # store the output in $g_output and the status in $g_status g_output=$( … Read more