perl - Why does this program use return with various different exit codes? -
what meaning of return different values in exit_code below:
sub exit_code { $testresult = shift; if ( $testresult eq "pass" ) { return 0; } elsif ( $testresult eq "fail" ) { return 1; } elsif ( $testresult eq "abort" ) { return 40; } else { print "invalid testresult argument passed..\n"; print "valid testresults are: pass, fail or abort\n"; } }
in *nix, programs have return values, can evaluated (e.g., using $?
environment variable). 0
means program completed without error. values larger 0
mean error occurred, , documentation should state each unique value means. while perl functions not share semantics of returning 0
upon successful execution, function presumably used return exit code for program.
Comments
Post a Comment