On Dec 14, 2007 10:01 PM, jeff pang <[EMAIL PROTECTED]> wrote:
snip
> When I complied it and run it:
>
> $ ./test
> hello world
>
> then get the value of $?:
>
> $ echo $?
> 1
>
> It's 1 not 0.
> How do you think about this case? :)
snip

If it is in-house, I would find the culprit and beat him or her for a
little while with Advanced Programming in the UNIX Environment (it is
about two inches thick and weighs two to three pounds). If it is
third-party software, I would either rewrite the functionality in
Perl, write a wrapper script, or just document the heck out of that
line of code.  My biggest concern would be what else is wrong with the
program if the author knew so little about UNIX programming that he or
she used a non-zero exit code for success.  Also note that $? in Perl
is not the same as $? in shell.  In shell it is the exit code; in Perl
it is the exit code (high byte) and the exec return value (low byte).
See $?'s entry in perldoc perlvar* or perldoc -f system** for more
information.

* http://perldoc.perl.org/perlvar.html#%24%3f
** http://perldoc.perl.org/functions/system.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to