Even more strange... Seems like the same batch file misbehaves when run from a path that contains space!

I got the correct output from test.bat when tested from a path with no spaces. I even added the following lines to test.bat:

if "%OS%"=="Windows_NT" set M2_HOME=%~dps0..
echo M2_HOME = %M2_HOME%

Result from path with NO space -- looks good:

C:\dev\walp>test.bat
~dps0: C:\dev\walp\
~dp0: C:\dev\walp\
~s0: C:\dev\walp\test.bat
~0: test.bat
~dps0\..: C:\dev\walp\\..
~dps0..: C:\dev\walp\..
M2_HOME = C:\dev\walp\..

When I run test.bat where maven2 is installed I get the file name! :

C:\Program Files\Maven 1.0.2\bin>test.bat
~dps0: C:\PROGRA~1\MAVEN-~1.0-A\bin\test.bat
~dp0: C:\Program Files\maven-2.0-alpha-1\bin\
~s0: C:\PROGRA~1\MAVEN-~1.0-A\bin\test.bat
~0: test.bat
~dps0\..: C:\PROGRA~1\MAVEN-~1.0-A\bin\test.bat\..
~dps0..: C:\PROGRA~1\MAVEN-~1.0-A\bin\test.bat..
M2_HOME = C:\PROGRA~1\MAVEN-~1.0-A\bin\test.bat..

Likewise, in some arbitrary path with spaces, same misbehaviour:

C:\dev\somewhere with space>test.bat
~dps0: C:\dev\SOMEWH~1\test.bat
~dp0: C:\dev\somewhere with space\
~s0: C:\dev\SOMEWH~1\test.bat
~0: test.bat
~dps0\..: C:\dev\SOMEWH~1\test.bat\..
~dps0..: C:\dev\SOMEWH~1\test.bat..
M2_HOME = C:\dev\SOMEWH~1\test.bat..

Even stranger... somehow in this path, it chomped off a letter off the file name when `dps` is used!:

C:\dev\path with space>test.bat
~dps0: C:\dev\PATHWI~1\test.ba
~dp0: C:\dev\path with space\
~s0: C:\dev\PATHWI~1\test.bat
~0: test.bat
~dps0\..: C:\dev\PATHWI~1\test.ba\..
~dps0..: C:\dev\PATHWI~1\test.ba..
M2_HOME = C:\dev\PATHWI~1\test.ba..

OK, this is weird... tried with another name with 4 char as the 1st token of the path with space, same thing!:

C:\dev\four with space>test.bat
~dps0: C:\dev\FOURWI~1\test.ba
~dp0: C:\dev\four with space\
~s0: C:\dev\FOURWI~1\test.bat
~0: test.bat
~dps0\..: C:\dev\FOURWI~1\test.ba\..
~dps0..: C:\dev\FOURWI~1\test.ba..
M2_HOME = C:\dev\FOURWI~1\test.ba..

OK, now I am really curious... chomped off 2 letters!

C:\dev\two with space>test.bat
~dps0: C:\dev\TWOWIT~1\test.b
~dp0: C:\dev\two with space\
~s0: C:\dev\TWOWIT~1\test.bat
~0: test.bat
~dps0\..: C:\dev\TWOWIT~1\test.b\..
~dps0..: C:\dev\TWOWIT~1\test.b..
M2_HOME = C:\dev\TWOWIT~1\test.b..

OK, I'm going to stop now... before I go insane... this time no double \\ !

C:\dev\foo bar>test.bat
~dps0: C:\dev\FOOBAR~1
~dp0: C:\dev\foo bar\
~s0: C:\dev\FOOBAR~1\test.bat
~0: test.bat
~dps0\..: C:\dev\FOOBAR~1\..
~dps0..: C:\dev\FOOBAR~1..
M2_HOME = C:\dev\FOOBAR~1..

Can this be reproduced on other windows or is it just my machine playing tricks on me???

Anyway, given all this, maybe on Windows, maven 2 should be installed to a path with NO space... or, use cygwin :-)

BTW, I don't have M2_HOME set outside of the batch file.


Brett Porter wrote:
Can you try this on win2000? Create test.bat:

@echo off
echo ~dps0: %~dps0
echo ~dp0: %~dp0
echo ~s0: %~s0
echo ~0: %~0

echo ~dps0\..: %~dps0\..
echo ~dps0..: %~dps0..

Then run: "cmd /C test.bat"

I get...
~dps0: c:\home\Brett\
~dp0: c:\home\Brett\
~s0: c:\home\Brett\test.bat
~0: test.bat
~dps0\..: c:\home\Brett\\..
~dps0..: c:\home\Brett\..

So it looks correct, though we could stand to drop the trailing \ as
it seems to incorporate that already.

Perhaps your M2_HOME is set differently outside of the batch file?

- Brett

On 4/17/05, baleineca <[EMAIL PROTECTED]> wrote:

I'm no batch file expert either and I thought it's was strange, but
here's what happens with the original line `if "%OS%"=="Windows_NT" SET
M2_HOME=%~dps0\..`:

M2_HOME = C:\PROGRA~1\MAVEN-~1.0-A\bin\m2.bat\..

which points to bin.

I also thought it was supposed to return the directory, but it's
returning the file (this is happening on win2000, I've seen batch
commands behave differently on various win versions, so maybe it's
correct on winXP?)

Hence my correction to go up one more from bin...


Brett Porter wrote:

Hi,

On 4/17/05, baleineca <[EMAIL PROTECTED]> wrote:


Change line 86 from:
if "%OS%"=="Windows_NT" SET M2_HOME=%~dps0\..

to

if "%OS%"=="Windows_NT" SET M2_HOME=%~dps0\..\\..

(need double \\ to escape)


Can you explain this to me? I'm no .bat file wizard, but I thought I
tested this.
IIRC, %~dps0 is the (d)rive and (p)ath of the batch file (%0), using a
(s)hort name.

So M2_HOME=c:\maven2\bin\..
which is correct. I thought yours would give c:\ in that case.

Thanks...
- Brett

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to