Bug #10749 Startup script fails if launched through symlink
Submitted: 19 May 2005 16:09 Modified: 1 Jun 2005 13:35
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Query Browser Severity:S3 (Non-critical)
Version: OS:Linux (Linux)
Assigned to: Vladimir Kolesnikov CPU Architecture:Any

[19 May 2005 16:09] [ name withheld ]
Description:
On linux, the script bin/mysql-query-browser incorrectly determines the mysql-query-browser base directory, if it is linked to by a symbolic link and this symlink is used to start the program. Hence the program cannot be started. 

How to repeat:
#ln -s /path/to/query/browser/bin/mysql-query-browser /usr/local/bin/mysql-query-browser
#mysql-query-browser

Suggested fix:
The following code taken from the Jakarta Ant project, as used in their startup script: 

#!/bin/sh

PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done

MYPATH=`dirname "$PRG"`

BASEPATH=`cd $MYPATH/.. ; pwd`

export MQB_DIR=$BASEPATH
[29 May 2005 0:58] Jorge del Conde
Thanks for your bug report.  I was able to reproduce this using FC2, and the latest version of QB.
[1 Jun 2005 13:35] Vladimir Kolesnikov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

thanks for the example