[ http://jira.codehaus.org/browse/MOJO-565?page=comments#action_83857 ] Mathieu Champlon commented on MOJO-565: ---------------------------------------
The bat script template has the same issue than the shell script template because of the lines that perform a cd, for instance right after the :WinNTGetScriptDir label : cd /d %0\..\.. However there is a second bug involved : %0 cannot be used to retrieve the full path of the script file. For example if I simply run my application with the command : my_app.bat (after having added my application bin directory to the path) Under the windows shell %0 will only contain my_app.bat whereas under cygwin %0 will contain the expected full path, like "c:\Program Files\My Application\bin\my_app.bat". The correct solution is to use %~dp0 instead, this is for example what ant or maven both do in their ant.bat and mvn.bat It has the advantage not to require a cd because %~dp0 automatically contains the expanded pathname of the script. However %dp0 does not work for win9x. So yes I believe the changes are required as without them the generated scripts do not work properly under the windows shell. > [appassembler] scripts change the current directory therefore relative pathes > become invalid > -------------------------------------------------------------------------------------------- > > Key: MOJO-565 > URL: http://jira.codehaus.org/browse/MOJO-565 > Project: Mojo > Issue Type: Bug > Components: appassembler > Environment: Cygwin using both .bat and sh scripts > Reporter: Mathieu Champlon > Priority: Critical > Attachments: MOJO-565.patch > > > The scripts change the current directory in order to compute BASEDIR. > For example in the .bat : > :WinNTGetScriptDir > cd /d %0\..\.. > And in the shell script : > # Change directory to the basedir > cd "$BASEDIR" > This is definitly a bad idea at least for the following reason : relative > pathes become invalid. > The solution would be either not to use cd in order to retrieve BASEDIR or to > change the current directory back afterwards. > For the .bat file maybe something like the following would be enough (that's > what is in mvn.bat) : > :setPaths > set BASEDIR=%~dp0.. > And for the shell script (again this comes from the mvn script) : > saveddir=`pwd` > ... > cd "$saveddir" > I'll try and make a patch if a can find some time in the following days. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email