Re: os.system return value left shifted 8 bits?

Tim Peters (tim@ksr.com)
Thu, 28 Apr 94 03:12:25 -0400

> .. os.system ... returns 256 when /bin/sh returns 1, and it returns 512
> when sh returns 2.
> ...
> Example:
> os.system('grep foo /dev/null') returns 256
>
> whereas the shell (and the man page) agree that the value is 1.

Ah, but _which_ man page <wink/sigh>? I suspect you're talking about the
man page for "grep". Try the man page for "system". Here, the latter
points to the man page for wait(2V), which in turn explains the results
you're seeing in all their convoluted glory. The man page for Perl's
"system" verb is less detailed but more helpful:

system LIST
... The return value is the exit status of the program as
returned by the wait() call. To get the actual exit value
divide by 256. ...

can't-tell-the-features-without-a-scorecard-ly y'rs - tim

Tim Peters tim@ksr.com
not speaking for Kendall Square Research Corp