Return-Path: Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 67669 invoked from network); 2 Feb 2001 01:53:20 -0000 Received: from pscgate.progress.com (192.77.186.1) by h31.sny.collab.net with SMTP; 2 Feb 2001 01:53:20 -0000 Received: from elvirus.progress.com (elvirus [192.77.186.100]) by pscgate.progress.com (8.10.2/8.10.2/PSC-4.01) with ESMTP id f121rSi10200 for ; Thu, 1 Feb 2001 20:53:28 -0500 (EST) Received: from progress.COM (localhost [127.0.0.1]) by elvirus.progress.com (8.10.2/8.10.2/PSC-4.01) with ESMTP id f121tbw21236 for ; Thu, 1 Feb 2001 20:55:37 -0500 (EST) Received: from naserv.bedford.progress.com (naserv [172.16.5.174]) by progress.COM (8.7.2/PSC-1.0) with ESMTP id UAA22701 for ; Thu, 1 Feb 2001 20:53:27 -0500 (EST) Received: from progress.com ([172.16.107.175]) by naserv.bedford.progress.com (Netscape Messaging Server 4.15) with ESMTP id G83X9300.1LC for ; Thu, 1 Feb 2001 20:53:27 -0500 Message-ID: <3A7A1316.A154E8DC@progress.com> Date: Thu, 01 Feb 2001 20:53:26 -0500 From: "Bill Burton" Organization: Progress Software Corporation X-Mailer: Mozilla 4.75 [en] (WinNT; U) X-Accept-Language: en-US,ja MIME-Version: 1.0 To: ant-user@jakarta.apache.org Subject: Re: Possible bug with failonerror attribute of exec task References: Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Hello, Running under Ant 1.2 and a recent 1.3alpha with the following batch file on Windows 4.0 SP5: fail.bat: @echo off dir xxx The following build file exectest.xml: Returns the following: D:\Work\anttest>ant -f exectest.xml -Dexec=fail.bat Buildfile: exectest.xml main: [exec] Volume in drive D has no label. [exec] Volume Serial Number is E8BD-8AE3 [exec] [exec] Directory of D:\Work\anttest [exec] [exec] File Not Found BUILD FAILED D:\Work\anttest\exectest.xml:6: Exec returned: 2 Total time: 2 seconds I tried using a JavaSoft JDK 1.2.2_007 and 1.3.0-C with the same results. So, I'm unable to reproduce any kind of a bug. As you can see, Ant gets the result of the batch file errorlevel. In my case, I don't have any other commands after the command causing the error. Then I added: echo ERRORLEVEL=%ERRORLEVEL% to the end of the batch file and the build stopped failing. The real bug it appears is in your batch file. Don't have any other commands after the command that could cause the error you're interested in. Even a REM or ECHO command will change the exit status!!! Note that I said "exit status" and not errorlevel. It appears the exit status of a program is copied to errorlevel. However, when the batch file exits it uses the exit status NOT errorlevel. Looks like a bug in cmd.exe to me. -Bill Burton Micha�l Smith wrote: > > I believe I have found a bug with the failonerror attribute of the exec > task. Here is part of my build.xml: > > > > > > executable="test.bat" os="Windows 2000" failonerror="True"/> > > > For the failonerror I tried "true" "True" "yes" "Yes". I'm not sure which > is correct because it's not documented. Here is my batch file: > > dir asdf > echo errorlevel = %ERRORLEVEL% > > This always has errorlevel = 1. > > Finally the output of my build: > > Ant version 1.2 compiled on October 24 2000 > > Buildfile: build.xml > Detected Java Version: 1.3 > Detected OS: Windows 2000 > Project base dir set to: Z:\Common\catapult\bin > Build sequence for target `test' is [test] > Complete build sequence is [test, init, shutdown_test_environment, tests, > build_tar, deploy_tar, init_test_environment, clean, usage, label, build] > > -- Building and executing tests: > > [exec] Myos = Windows 2000 > [exec] test.bat > [exec] > [exec] Fichier introuvable > [exec] Z:\customer_registry\customer\build>dir asdf > [exec] Le volume dans le lecteur Z s'appelle CCase > [exec] Le num‚ro de s‚rie du volume est 0234-5789 > [exec] > [exec] R‚pertoire de Z:\customer_registry\customer\build > [exec] > [exec] > [exec] Z:\customer_registry\customer\build>echo errorlevel = 1 > [exec] errorlevel = 1 > > BUILD SUCCESSFUL > > Total time: 1 second > > Micha�l