|
|
| go ahead... be a heretic | |
| PerlMonks |
Re: getting the bash exit codeby Perlbotics (Monsignor) |
| on Aug 24, 2012 at 18:54 UTC ( #989613=note: print w/ replies, xml ) | Need Help?? |
|
Now I have no idea how it got 25856 from 101 (well it does seem to be 101 times that magical 256 number, but I'm sure it isn't that simple). Yes, it's that simple. perlvar explains that $? is set like explained in system where the following snippet is copied from: Quote from system: HTH Update:
Update2 (in response to node below): So for quick and dirty every day use it sounds like I can just say something like: $exit_status = $?/255;No. Use int() to get rid of potential fractional parts when the process terminated due to a signal or core-dump. The >>-operator does this in a single step. I might note, that I assumed a *NIX background. The Windows emulation might not cover the whole interface (exit-code plus signals). Other monks will know better... So X >> Y is most of the time int( X / (2**Y) ) for positive numbers. Here are some starters for binary arithmetic: wikibooks, Khan Academy - Binary Numbers, Slideshare - Binary Arithmetic, ... Search also MIT OpenCourseWare - I am sure, they have something in their repertoire.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||