develooper Front page | perl.perl5.porters | Postings from January 2004

Re: [perl #25369] perlbug: 5.8.2 ActivePerl $CHILD_ERROR wrong with 2>&1 after qx

Thread Previous | Thread Next
Dave Mitchell
January 31, 2004 14:33
Re: [perl #25369] perlbug: 5.8.2 ActivePerl $CHILD_ERROR wrong with 2>&1 after qx
Message ID:
On Tue, Jan 27, 2004 at 06:41:45PM -0000, Flash Sheridan wrote:
> -----------------------------------------------------------------
> The following code incorrectly prints -1 under Perl v5.8.2 build 808, but 
> correctly prints 0 for 5.6.1 build 631, with CygWin true.
>      CygWin's true is working correctly, as verified by echo %ERRORLEVEL%; 
> I originally noticed the problem with
> an internal tool.  More complicated code relying on the expected behavior 
> has been working for over a year.
>      Because of ActiveState's warning about dual installations, I haven't 
> yet tried both versions of Perl on the same machine;
>      the bug is on a new Windows XP box.
> use strict; use warnings; use diagnostics; use English; use 5.6.0;
> my $theSysText = qx("true 2>&1");
> print "\nCHILD_ERROR: $CHILD_ERROR\n";

First, a disclaimer - I don't use Windows, so some of the following is
speculative. However, the '2>&1' syntax is specific to UNIX (Bourne-like)
shells, and is unlikely to work under Windows. A return code of -1
usually means that Perl was unable to execute the command. For example on
my Linux system:

$ ./perl -e '$a=`/xxx`; print "\$?=$? \$a=[$a] \$!=[$!]\n"'
$?=-1 $a=[] $!=[No such file or directory]

Try printing out $! to see what the error is, then see if the problem goes
away by removing the 2>&1.


Monto Blanco... scorchio!

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About