use IPC::System::ExitValue qw/assert_exit/; system( "foo", @args ) and assert_exit( 0 .. 5 );