in reply to [Win32] Successful system() call returns 256

autodie, IPC::System::Simple, eval
$ echo Hello >t1.txt $ echo World >t2.txt $ perl -wle " $ret = system q[diff -u t1.txt t2.txt >NUL 2>&1] ; print + $ret; print $?" 256 256 $ perl -Mautodie=system -wle " $ret = system q[diff -u t1.txt t2.txt > +NUL 2>&1] ; print $ret; print $?" "diff -u t1.txt t2.txt >NUL 2>&1" unexpectedly returned exit value 1 a +t (eval 10) line 13 at -e line 1 $ perl -MIPC::System::Simple=system -wle " $ret = system q[diff -u t1. +txt t2.txt >NUL 2>&1] ; print $ret; print $?" "diff -u t1.txt t2.txt >NUL 2>&1" unexpectedly returned exit value 1 a +t -e line 1
After consulting
$ diff --help |grep -i exit Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
and some docs, you don't need eval, you could write
$ perl -MIPC::System::Simple=system -wle " $ret = system [0,1], q[diff + -u t1.txt t2.txt >NUL 2>&1] ; print $ret; print $?" 1 256 $ perl -Mautodie=system -wle " $ret = system [0,1], q[diff -u t1.txt t +2.txt >NUL 2>&1] ; print $ret; print $?" 1 256
[0, 1] are acceptable exit value, any others and IPC::System::Simple will croak

Replies are listed 'Best First'.
Re^2: [Win32] Successful system() call returns 256
by syphilis (Archbishop) on Jun 07, 2011 at 00:00 UTC
    Yeah - thanks guys.
    Like you say, it's just diff doing what it's supposed to do.

    Cheers,
    Rob