You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stefan Krause <st...@snafu.de> on 2009/02/26 15:16:04 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
If I define a property containig more than one "$", ant strips some
of them.
<project name="test" default="make" basedir=".">
<property name="test" value="foo$$$$$bar"/>
<target name="make">
<echo>${test}</echo>
</target>
</project>
foo$bar -> foo$bar
foo$$bar -> foo$bar
foo$$$bar -> foo$$bar
foo$$$$$bar -> foo$$bar
Is there any trick to keep the original string?
Thanks,
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFJpqQkeiBYJLd+QfQRAvAnAJ4/wzDH3uhXgGBEIlpM2OACvhXe7QCbBqK1
FkabyHzpPL1RPfqo7Ox7BKs=
=Pp4o
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re:
Posted by Joe Schmetzer <jo...@exubero.com>.
Ant will unconditionally substitute a double "$$" with a single "$", as
this is the escape mechanism for avoiding property expansion. See
http://ant.apache.org/manual/using.html#properties for details.
Cheers,
Joe
On Thu, February 26, 2009 2:16 pm, Stefan Krause wrote:
> If I define a property containig more than one "$", ant strips some
> of them.
>
> <project name="test" default="make" basedir=".">
> <property name="test" value="foo$$$$$bar"/>
> <target name="make">
> <echo>${test}</echo>
> </target>
> </project>
>
> foo$bar -> foo$bar
> foo$$bar -> foo$bar
> foo$$$bar -> foo$$bar
> foo$$$$$bar -> foo$$bar
>
> Is there any trick to keep the original string?
>
> Thanks,
>
> Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re:
Posted by Brian Stephenson <bs...@thortech-solutions.com>.
Stefan,
The ant property task can take predefined properties, in the
format "${property}", as part of a value (such as "${base.dir}/src"),
so I suspect the behavior is related to the fact that the first time
ant sees a dollar sign it thinks it will get a property, and then when
it sees another $ it knows it isn't going to get one, so it drops the
first one. It looks like ant drops every even $ (the second, the
fourth, etc.) and leaves the odd ones alone. Strange behavior. I
tried regular expression escaping the character, but that did not work.
Still, THIS workaround actually gives you what you want, use it if you
like:
<project name="test" default="make" basedir=".">
<property name="dollar" value="$"/>
<property name="test" value="foo${dollar}${dollar}${dollar}$
{dollar}bar"/>
<target name="make">
<echo>${test}</echo>
</target>
</project>
Brian
On Feb 26, 2009, at 9:16 AM, Stefan Krause wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> If I define a property containig more than one "$", ant strips some
> of them.
>
> <project name="test" default="make" basedir=".">
> <property name="test" value="foo$$$$$bar"/>
> <target name="make">
> <echo>${test}</echo>
> </target>
> </project>
>
> foo$bar -> foo$bar
> foo$$bar -> foo$bar
> foo$$$bar -> foo$$bar
> foo$$$$$bar -> foo$$bar
>
> Is there any trick to keep the original string?
>
> Thanks,
>
> Stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFJpqQkeiBYJLd+QfQRAvAnAJ4/wzDH3uhXgGBEIlpM2OACvhXe7QCbBqK1
> FkabyHzpPL1RPfqo7Ox7BKs=
> =Pp4o
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>