Bug 41890 - exec > env > key value not set correctly.
Summary: exec > env > key value not set correctly.
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Build Process (show other bugs)
Version: 1.7.0
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-19 07:58 UTC by Cliff Hupper
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 Cliff Hupper 2007-03-19 07:58:36 UTC
S:\auth\dev\auth3>ant -version
Apache Ant version 1.7.0 compiled on December 13 2006


I'm not sure if this is by design or not, but I can't find it doc'd and it does
cause some confusion.

Essentially, you can't set a path for an env var that does not contain a '\'.

For instance:
<env key="SystemDrive" path="c:"/>
Results in
SystemDrive=S:\auth\dev\auth3\c

Where s:\auth\dev\auth3 is your working directory.

To show this, it's easiest to create a target that allows you to view your env.
For another reason, I can't just launch a cmd window.  I don't know why. 
Perhaps this can be explained as well?

In any case, I create a target named taskmgr that spawns taskmgr with a new env
and just a couple of vars set.  See below.

So, launch the target and then view its env.
Do this by running a command prompt via taskmgr > file > run.
Then type set to view your env vars.


<target name="taskmgr">
  <exec dir="c:\windows\system32\" executable="c:\windows\system32\taskmgr.exe"
newenvironment="true" >
	
    <env key="junk" path="c:" />
    <env key="SystemDrive" value="c:"/>


env vars are...

COMSPEC=C:\windows\system32\cmd.exe
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS
PROMPT=$P$G
junk=S:\auth\dev\auth3\c
SystemDrive=c:

Note, junk is _incorrect_
Yet SystemDrive is correct.

Why do you need to use value to set c:
Isn't it a valid path?  And why is it appended otherwise?
Is this doc'd?
Comment 1 Benjamin Burgess 2007-03-19 08:05:42 UTC
On a windows box, c: != c:\
Windows requires all Paths to have at least one '\' character to be valid.

For example, open a command prompt and change the directory to anything other
than the root.  Then type "cd c:" and it will not take you to the root.  Now
type "cd c:\" and it will.

Not sure if this helps (or is relevant), just thought I would share.
Comment 2 Cliff Hupper 2007-03-19 08:23:25 UTC
Yes, I understand that c: is not c:\

Perhaps I should ask, why a partial path is _cleaned_ and then appended to the
working direcotry, Is that a bug?  Is that doc'd?

why does
<env key="junk" path="c:" />
result in
junk=S:\auth\dev\auth3\c

Where is this doc'd?
why is the ':' trimmed?

I found the behavior ambiguous.
Comment 3 Steve Loughran 2007-03-19 08:28:02 UTC
: is one of the supported path separators. So Ant doesnt know that "c:" refers
to "./c" : "" or or c:\. 

1. what does c:; get picked up as?
2. what does <env key="systemdrive" file="c:" /> get picked up as. Because there
it is explicitly a file, not a path.
Comment 4 Matt Benson 2007-03-19 09:00:29 UTC
(In reply to comment #3)
> : is one of the supported path separators. So Ant doesnt know that "c:" refers
> to "./c" : "" or or c:\. 
> 
> 1. what does c:; get picked up as?
> 2. what does <env key="systemdrive" file="c:" /> get picked up as. Because there
> it is explicitly a file, not a path.

Ah, I forgot that.  Yes, while c: => ${pwd}/c is understandable, one would hope
that c:; => (windows) c:${context} .  In my tests, it is apparently interpreted
as c:;=>"c"PATHSEP""PATHSEP=>${pwd}/c .