Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved win short directory conversion into bash #347

Merged
merged 1 commit into from
Feb 16, 2016
Merged

Conversation

TylerJewell
Copy link

Signed-off-by: Tyler Jewell tjewell@codenvy.com

Two sets of changes:

  1. Moved CHE_HOME short directory conversion of windows from che.bat into che.sh. Thanks @SamHasler.
  2. Convert JAVA_HOME to short directory if on Windows.

Signed-off-by: Tyler Jewell <tjewell@codenvy.com>
@TylerJewell
Copy link
Author

@garagatyi @eivantsov wdyt?

TylerJewell pushed a commit that referenced this pull request Feb 16, 2016
Moved win short directory conversion into bash
@TylerJewell TylerJewell merged commit 9c3a926 into master Feb 16, 2016
@TylerJewell TylerJewell deleted the che-493 branch February 16, 2016 16:25
@SamHasler
Copy link

That will fail if the che.sh isn't invoked from the directory it is in.

Try this:

echo `(cd "$( dirname "${BASH_SOURCE[0]}" )" && cmd //C 'FOR %i in (..) do @echo %~Si')`

The %~dp0 variable only works in the context of a batch script. By invoking cmd and passing it as a command there is no script name or %0 parameter set. So %i ends up as %~dp0\..\... I'm not sure how but %~Si is then geting evaluated to the short name directory of the dir below the current directory.

e.g.:

echo `(cmd //C 'echo %0')`
echo `(cmd //C 'FOR %i in (%~dp0\..\..) do @echo %i')`
echo `(cmd //C 'FOR %i in (%~dp0\..\..) do @echo %~Si')`
echo `(cd "$( dirname "${BASH_SOURCE[0]}" )" && cmd //C 'FOR %i in (..) do @echo %~Si')`

invoked from "C:\VERY LONG\PATH\WITH SUBDIR" using ./testscript.sh outputs:

%0         
%~dp0\..\..
C:\VERY~1\PATH~1\
C:\VERY~1\PATH~1\

invoked from "C:\Some\Other\Dir" using "/c/very long/path/with subdir/testscript.sh" outputs:

%0         
%~dp0\..\..
C:\SOME~1\OTHER~1\
C:\VERY~1\PATH~1\

@TylerJewell
Copy link
Author

Yep - good catch. I thought our tests caught that scenario, but it didn't.
BTW, we convert JAVA_HOME now to its short path using the cycgpath utility that you pointed out. Didn't know that existed. Would have saved me 4 hours the first time I tried to solve this :-/

@SamHasler
Copy link

Glad I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants