[Tfug] Problem checking return code in bash script

Chad Woolley thewoolleyman at gmail.com
Mon Oct 5 21:23:40 MST 2009


I'm writing a script which automates system setup, with logic like this:

sudo su -l -c "ruby ~/railsci/setup_rails_dependencies.rb" ci
if [ ! $? = 0 ]; then echo "Unable to setup rails dependencies" && exit; fi

However, even if the command returns a non-zero return code (tested by
running manually), the script keeps going and doesn't exit.

What am I doing wrong?  References/links to docs are welcome.

Thanks,
-- Chad




More information about the tfug mailing list