On Jul 18, 12:59pm, Roman Cheplyaka wrote: } } I want to check exit code of some command through the $? variable # ---- function laststatus { return $? } false if laststatus; then echo true; else echo false; fi # ---- You don't even need the $? for it to work, but it makes it more obvious what's going on.