From billb@progress.com Sun Jan 28 02:20:34 2001 Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 80574 invoked from network); 28 Jan 2001 02:20:34 -0000 Received: from pscgate.progress.com (192.77.186.1) by h31.sny.collab.net with SMTP; 28 Jan 2001 02:20:34 -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 f0S2Kei28309 for ; Sat, 27 Jan 2001 21:20:40 -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 f0S2MjT29218 for ; Sat, 27 Jan 2001 21:22:45 -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 VAA06963 for ; Sat, 27 Jan 2001 21:20:38 -0500 (EST) Received: from progress.com ([172.16.107.175]) by naserv.bedford.progress.com (Netscape Messaging Server 4.15) with ESMTP id G7UP6E00.8AQ for ; Sat, 27 Jan 2001 21:20:38 -0500 Message-ID: <3A7381F6.84568077@progress.com> Date: Sat, 27 Jan 2001 21:20:38 -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 Developers Mailing List Subject: [PATCH] ant.bat - fix for -D args with spaces Content-Type: multipart/mixed; boundary="------------A6AEC30C6C3819CDB85E6880" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N --------------A6AEC30C6C3819CDB85E6880 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello, Here is a patch to ant.bat which fixes problems with spaces in the value specified by a property such as -Dfoo="a b c". Between the Ant 1.2 release and the current CVS version, someone changed the test in the argument looping from %1a==a to "%1"=="" which broke the way quoted arguments are appended together causing the script to fail. In addition to reverting this change, I made a small optimization for NT/2K so %* is used to grab all the arguments instead of looping to get them. As a result, I renamed the target from "start" to "win9xArgs" which is now more accurate. Also made minor changes to a few of the comments. This fix was tested on Windows NT 4.0 SP5 and Windows 98SE. Here's a simple build file, proptest.xml: p1="${p1}" p2="${p2}" p3="${p3}" Sure -debug will output the properties but you have to run against some build file. Here is a sample command: ant -f proptest.xml -Dp1="C:\Prog files" -Dp2=hello2 -Dp3="D:\ant home" which should output: main: [echo] p1="C:\Prog files" p2="hello2" p3="D:\ant home" -Bill Burton --------------A6AEC30C6C3819CDB85E6880 Content-Type: text/plain; charset=us-ascii; name="ant.bat.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ant.bat.diff.txt" --- ant.bat.orig Sat Jan 13 01:10:58 2001 +++ ant.bat Fri Jan 26 00:29:03 2001 @@ -2,7 +2,7 @@ if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat" -if not "%OS%"=="Windows_NT" goto start +if not "%OS%"=="Windows_NT" goto win9xArgs rem %~dp0 is name of current script under NT set DEFAULT_ANT_HOME=%~dp0 @@ -13,22 +13,24 @@ if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME% set DEFAULT_ANT_HOME= -:start - -rem Slurp the command line arguments. This loop allows for an unlimited number of -rem agruments (up to the command line limit, anyway). +rem On NT/2K grab all arguments at once +set ANT_CMD_LINE_ARGS=%* +goto doneArgs + +:win9xArgs +rem Slurp the command line arguments. Allow for an unlimited number of +rem arguments (up to the command line limit, anyway). set ANT_CMD_LINE_ARGS= - :setupArgs -if "%1"=="" goto doneArgs +if %1a==a goto doneArgs set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 shift goto setupArgs :doneArgs -rem The doneArgs label is here just to provide a place for the argument list loop -rem to break out to. +rem This label provides a place for the argument list loop to break out +rem and for NT handling to skip to. rem find ANT_HOME if not "%ANT_HOME%"=="" goto checkJava --------------A6AEC30C6C3819CDB85E6880--