[Tfug] Problem checking return code in bash script

Chad Woolley thewoolleyman at gmail.com
Tue Oct 6 09:45:10 MST 2009


On Tue, Oct 6, 2009 at 9:35 AM, Chad Woolley <thewoolleyman at gmail.com> wrote:
> On Tue, Oct 6, 2009 at 1:57 AM, Choprboy <choprboy at dakotacom.net> wrote:
>> Your program is testing the exit status of the command you gave, i.e.
>> the "sudo". The sudo suceeded... it was the sudo'd command that failed. The
>> sudo creates a subshell, and the su also creates a subshell, so your are
>> really 3 subshells down when executing ruby. The upper shell completed
>> successfully.
>
> Thanks for explaining.  Is there no way to make sudo and su bubble up
> the return code?

Also, when I run the complete command, including sudo and su, from the
command line manually, sudo DOES properly return a nonzero return code
(I will double check, though).  This problem only seems to happen in
this script.




More information about the tfug mailing list