Bug 41307 - Single quoted command line properties are evaluated before being passed
Summary: Single quoted command line properties are evaluated before being passed
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Wrapper scripts (show other bugs)
Version: 1.7.0
Hardware: Other other
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-05 17:18 UTC by Philippe Lantin
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Lantin 2007-01-05 17:18:38 UTC
As of version 1.6.2, the ant launcher shell script evaluates single quoted
properties given on the command line (-D). This causes the expansion of system
variables and backtick quoted commands. This is not correct behavior for single
quoted properties.

The "ant" shell script uses: (line 38 in ant 1.7.0)

ant_exec_args="$ant_exec_args \"$arg\""

This fixes the problem: (but may not be the final solution)

ant_exec_args="$ant_exec_args '$arg'"

Here is a test that compares 1.6.1 behavior and 1.6.2, as well as 1.7.0. This
test has been run on Linux RedHat-AS 4.0u3.

Buildfile: tt.xml

linux$ ant -Dthis.variable='`cd /tmp; pwd`' -f tt.xml test
test:
     [echo] Ant version: Apache Ant version 1.6.1 compiled on February 12 2004
     [echo] this.variable: `cd /tmp; pwd`
     [exec] `cd /tmp; pwd`



BUILD SUCCESSFUL
Total time: 0 seconds
linux$ ant -Dthis.variable='`cd /tmp; pwd`' -f tt.xml test
Buildfile: tt.xml

test:
     [echo] Ant version: Apache Ant version 1.6.2 compiled on July 16 2004
     [echo] this.variable: /tmp
     [exec] /tmp

BUILD SUCCESSFUL
Total time: 0 seconds
linux$ ant -Dthis.variable='`cd /tmp; pwd`' -f tt.xml test
Buildfile: tt.xml

test:
     [echo] Ant version: Apache Ant version 1.7.0 compiled on December 13 2006
     [echo] this.variable: /tmp
     [exec] /tmp

BUILD SUCCESSFUL
Total time: 0 seconds

Ant test:

<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="all" basedir=".">
  <target name="all"></target>
  <target name="test">
   <echo message="Ant version: ${ant.version}"/>
   <echo message="this.variable: ${this.variable}"/>
    <exec executable="echo">
      <arg line="${this.variable}"/>
    </exec>
  </target>
</project>