in reply to Re: system call returns incorrect in windows
in thread system call returns incorrect in windows

My bad, I said above that ant was exe, but it is in fact, .bat, or .cmd. However the search order in windows is PATHEXT=.COM;.EXE;.BAT;.CMD...

I tried providing the full path to ant.bat and am seeing the same type of results. The cmd version apparently has bugs and won't run at all.

I checked out the ant.bat file and it appears to be setting the err variable in the file in the event of an error. In any event, when executing it directly from the command prompt it does leave %ERRORLEVEL% set to 1. Not sure if that is what system() consults or not?

  • Comment on Re^2: system call returns incorrect in windows

Replies are listed 'Best First'.
Re^3: system call returns incorrect in windows (use antRun)
by Anonymous Monk on Apr 07, 2018 at 03:31 UTC

    Hi,

    ERRORLEVEL merely reflects errno, and that can change each time you execute a command

    I think the problem is the /b in  exit /b %ANT_ERROR%

    here is why

    $ perl -le" print system 'errorexit1.bat' " $ exit 1 256 $ perl -le" print system 'errorexitb1.bat' " $ exit /b 1 0 $

    This tells me you are probably supposed to system antRun.bat or https://github.com/apache/ant/blob/master/src/script/antRun.pl

      I didn't get the same results. I'm running Windows 8 with 64bit Perl. What are you using?

      C:\Users\Lotus1>perl -v This is perl 5, version 22, subversion 1 (v5.22.1) built for MSWin32-x +64-multi-thread [...] C:\Users\Lotus1>perl -e" print system 'test1.bat' " C:\Users\Lotus1>exit 1 256 C:\Users\Lotus1>perl -e" print system 'test1b.bat' " C:\Users\Lotus1>exit /b 1 256
        strawberry-perl-5.20.3.3-32bit and older on older windows