Getting script location, trouble with spaces
Hi,
I am writing a script and in order to run properly it needs to know
where it is located, in order to be able to find its resources. It
works fine, until the path has a space in it. I having a little
trouble resolving the issue.
#!/bin/sh
cd `dirname "$0"`
pwd
java -cp lib/myjar.jar:lib/icu4j-3_8.jar osj.main.MainClass
If at the route I have two folders:
/Applications
/Applications (Java)
and my script is in the "Applications (Java)" folder, then I always
end up in the Applications folder. At the same time if I call:
dirname "/Applications (Java)/MyApp/myapp.sh"
then this works as should.
Can anyone suggest a solution to my problem?
Andre
|