Bug 18407 - [ExternalTools] Run External - Command variables not working?
Summary: [ExternalTools] Run External - Command variables not working?
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.0   Edit
Hardware: Other Windows 98
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Simon Arsenault CLA
QA Contact:
URL:
Whiteboard:
Keywords: ui
Depends on:
Blocks:
 
Reported: 2002-05-31 00:20 EDT by Dave Thomson CLA
Modified: 2002-09-18 13:58 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Thomson CLA 2002-05-31 00:20:27 EDT
As far as I can tell, no command variables are being passed to the external 
program.  I tried both current project location and selected resource 
location.  I set up an external program with both c:\windows\write.exe and 
c:\windows\command.com and neither seems to be passed the variable contents.  
Although if I type a specific non-variable parameter into the "Tool Arguments" 
field, that works.
Comment 1 Dave Thomson CLA 2002-05-31 00:21:35 EDT
Build was 0530 integration build.
Comment 2 Nick Edgar CLA 2002-05-31 10:16:22 EDT
Need to ensure that all the variables we claim to support are working for F2.
Comment 3 Nick Edgar CLA 2002-06-04 16:01:57 EDT
Please verify.
Comment 4 Dave Thomson CLA 2002-06-09 12:59:58 EDT
Checked build 0609, using NT and Win98.
As far as I can tell this is *not* working.
I configured an external tool definition for wordpad.exe (write.exe on win98).
I tried both the following variables:
selected resource location
selected resource full path

It appears that no parameters are being passed to the program.
If I type a constant parameter into the dialog then it works.
Comment 5 Chris McLaren CLA 2002-06-09 23:39:55 EDT
i wrote a program, c:\args.cmd, which looks like this:

echo [0] %0
echo [1] %1
echo [2] %2
echo [3] %3
echo [4] %4
echo [5] %5
echo [6] %6
echo [7] %7
echo [8] %8
echo [9] %9

a created ten tools from this program, one for each of the first ten variables 
as the tool's single argument. from my workspace (built from importing the 
plugins), i selected in navigator a file resource: "plugin.xml" 
under "org.junit".

i ran each tool on this selection with the following results (as displayed in 
the log console; irrelevant details omitted):

args ${workspace_loc}
[0] c:\args.cmd
[1] C:/eclipse-SDK-20020607-win32/eclipse/workspace

args ${project_loc}
[0] c:\args.cmd
[1] C:/eclipse-SDK-20020607-win32/eclipse/workspace/org.junit

args ${container_loc}
[0] c:\args.cmd
[1] C:/eclipse-SDK-20020607-win32/eclipse/workspace/org.junit

args ${resource_loc}
[0] c:\args.cmd
[1] C:/eclipse-SDK-20020607-win32/eclipse/workspace/org.junit/plugin.xml

args ${project_path}
[0] c:\args.cmd
[1] /org.junit

args ${container_path}
[0] c:\args.cmd
[1] /org.junit

args ${resource_path}
[0] c:\args.cmd
[1] /org.junit/plugin.xml

args ${project_name}
[0] c:\args.cmd
[1] org.junit

args ${container_name}
[0] c:\args.cmd
[1] org.junit

args ${resource_name}
[0] c:\args.cmd
[1] plugin.xml

wordpad:

now i created two tools using wordpad (C:\Program Files\Windows 
NT\Accessories\wordpad.exe), the first using ${resource_loc} as its argument. 
with the same selection as above, wordpad launches the file correctly.
i am not able to repeat your problem for this case. 

the second, using ${resource_path} as its argument, causes wordpad to launch, 
but wordpad is unable to launch the file so it starts with a blank document. 
this is also correct behavior according to the above tests. wordpad cannot 
find "/org.junit/plugin.xml"

(note: it is unfortunate that the full path variables always have a leading 
slash, otherwise i could have been able to launch in this case by specifying 
${workspace_loc} as the working directory.)

there are a two areas where you may have had problems (i stumbled on both of 
them myself):

potential issue #1: paths with spaces

eclipse has no problem executing applications with spaces in the path. quotes 
are not required. interpretation of arguments, of course, is up to the tool 
itself, and occasionally a tool will fail on a filename containing spaces
unless it is explicitly quoted. eclipse does not seem to quote arguments with 
spaces, and i feel that this is correct behavior. wordpad will fail on 
filenames containing spaces unless explicitely quoted. this may have happened 
in your case. 

potential issue #2: selection bug

try the args ${resource_loc} example above again. make sure to select a 
resource first. notice that the current view (probably navigator if you just 
selected a resource) deactivates when the tool is run. when the tool finishes, 
the view doesn't reactivate. notice the resource is still selected, but colored 
gray. try running the tool again. the argument expands to an empty string as 
the view does not return a selected resource. try this with the wordpad 
${resource_loc} example and you will get a blank document. 

finally, a note about the variable terminology:

as a regular user, my first thought is that "full path" and "location" should 
be swapped. "full path" intuitively means an absolute path on a file system, 
while "location" is a more abstract notion - more useful a term to describe a 
relative position within a domain-specific semantic construct like 'workspace'
external tools is not to blame: during variable expansion it correctly 
delegates to IResource.getFullPath() and IResource.getLocation() respectively, 
and i think the ui is correct to match its terminology to core resources
public api. i do find it curious why core resources didn't swap these terms.

summary:
1. i will log the leading slash comment and the selection bug to platform ui.
2. i will log the comment regarding confusing terminology to core resources.
3. i will log a note to platform docs requesting special attention to 
explaining variable names and the issue with filenames containing spaces.
Comment 6 Dave Thomson CLA 2002-06-10 09:36:38 EDT
Quoting the argument fixed the problem.
However users are going to run into trouble for the reasons you outline:
1) Without quotes some apps don't work and you have no clue why.  I wonder why 
we don't just insert the quotes into the text area for the arguments by 
default?  The user can always remove them.

2) The terminology for the arguments is confusing and conterintuitive - we need 
a better way to indicate what exactly will be passed as the argument - perhaps 
we could show what would be passed given the current selection, or provide a 
test area so you can click on something and see what happens.
Comment 7 Dave Thomson CLA 2002-06-10 09:45:12 EDT
Actually, it only worked the first time.  After some experimentation I 
discovered I had to re-click on the item in the list to make it work again.
I am reopening the report because there is still a real problem here.
Comment 8 Simon Arsenault CLA 2002-06-10 09:58:26 EDT
Ryan was looking at quoting the arguments being passed (both for location and 
path variables). It was not part of friday's build.

I agree, we exposed the core terminology in the UI - coming up with better 
names for these would help.

The lost of focus may come from the use of a progress monitor. This problem may 
go away if we can run without a progress monitor.
Comment 9 Nick Edgar CLA 2002-06-14 15:26:58 EDT
The variables are now working.
The selection problem and the terminology will have to wait until post 2.0.
Comment 10 Nick Edgar CLA 2002-06-14 15:51:16 EDT
Post 2.0.
Comment 11 Randy Giffen CLA 2002-08-12 10:38:55 EDT
Reopened for investigation
Comment 12 Simon Arsenault CLA 2002-09-06 14:59:02 EDT
This is fixed in the new external tool support.

Note: new external tool work is not yet released to the head stream and won't 
for a while yet.