#152 'shellscript' task in the same target cannot be run twice

v1.0 (example)
platform (5)

If a target contains the 'shellscript' task, and if
during one invocation of Ant this target is executed
twice, the second invocation fails with something along
the lines of

[shellscript] /bin/sh: /tmp/script2023260757null:
Datei oder Verzeichnis nicht gefunden

(the error message translates to "file not found")

Steps to reproduce:

1) create a build.xml with a target "foo" containing a
'shellscript' task
2) run "ant foo foo"

I also think I have found the reason for this behaviour:

In the execute() method of the 'ShellScriptTask' (which
inherits from 'ExecTask'), the super class method
createArg() is being called and the name of the
temporary shell script file is set. To my
understanding, Ant creates one instance of the
'ShellScriptTask' class per occurrence in the build.xml
file. Thus, if execute() is being called the second
time, yet *another* Arg gets created and added. The
first Arg which still exists however points to a temp
file which is already deleted. Consequently, the next
invocation of super.execute() then fails due to a 'file
not found' error.

I haven't tested this since I wasn't able to get the
source distribution of 'ant-contrib' to compile, but I
would suggest a bugfix along the following lines:

1) invoke super.createArg() only once (through lazy
init maybe) and assign it to an instance field
2) in the execute() method, call setValue() on the
instance field

This should make sure that there is only one command
line arg that always contains the proper file name.

BTW: We here find 'ant-contrib' really helpful. Keep up
the good work :-)




  • Matt Inger

    Matt Inger - 2006-08-09
    • assigned_to: nobody --> mattinger
  • peterkittreilly

    peterkittreilly - 2006-10-11

    Logged In: YES

    Thanks for the bug report.
    I will look into a fix.
    Note that due to a change in
    processing in Ant, the example
    will work with Ant 1.7.0.
    (in ant 1.7.0beta3 but not ant 1.7.0beta2).


Log in to post a comment.