Reputation
827
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
2 10 29
Newest
 Yearling
Impact
~75k people reached

Jan
29
awarded  Yearling
Jan
4
awarded  Popular Question
Dec
8
awarded  Popular Question
Nov
25
awarded  Popular Question
Oct
11
awarded  Notable Question
Jul
30
awarded  Nice Question
Jul
7
awarded  Informed
Apr
27
awarded  Notable Question
Apr
18
awarded  Famous Question
Apr
9
awarded  Famous Question
Jan
29
awarded  Nice Question
Jan
29
awarded  Yearling
Jan
11
accepted Save exit code for later
Jan
11
comment Save exit code for later
So with your update I would have to initialize last_error_code to zero and then return at the end so I would have non-zero exit code if any command threw an error? It is a cool trick, but for my two line hack script, I think I prefer @mikeserv 's answer.
Jan
11
comment Save exit code for later
Ah I agree it's better than my original. But it still feels unsatisfactory that I have to explicitly store the exit code to a variable. Is there no way to 'push' an exit code and 'pop' it again later?
Jan
11
asked Save exit code for later
Sep
27
awarded  Notable Question
Sep
20
awarded  Popular Question
Sep
7
awarded  Nice Question
Aug
15
awarded  Popular Question