patric-r / jvmtop

Java monitoring for the command-line, profiler included
GNU General Public License v2.0
1.22k stars 252 forks source link

allow jvmtop.sh to be called from a symlink #95

Open muxator opened 7 years ago

muxator commented 7 years ago

With this change jvmtop.sh can be symlinked in a directory in the PATH and called from anywhere.

$  ls -l /usr/local/bin/jvmtop.sh
lrwxrwxrwx 1 root root 32 Dec 13 21:46 /usr/local/bin/jvmtop.sh -> /opt/jvmtop with space/jvmtop.sh

Before the change:

$ jvmtop.sh
Error: Could not find or load main class com.jvmtop.JvmTop

After the change it works, even if the script is a symlink, and if spaces are contained in the path.

Source for the change: http://stackoverflow.com/questions/59895/getting-the-current-present-working-directory-of-a-bash-script-from-within-the-s#comment54598418_246128