#49 Fix gantproject.sh to work with symlinks

open
nobody
5
2012-07-18
2007-11-15
Matthieu Moy
No

Context :
I usually install software by compiling it in ~/local/, and then create a symbolic link to them in ~/bin/.

Problem :
ganttproject.sh tries to find its related files in the directory where the executable is ($0). In my case, it searches in ~/bin/, and finds nothing.

Solution :
Use readlink untill the script finds the actual script.
See attached patch.

Discussion

  • paopap
    paopap
    2011-03-05

    Hi ,
    Matthieu Moy is right, the Linux shell script for running does not handle symlinks right.
    I propose a solution for the same problem, but simpler (I cannot see a wasy to attach another patch, so I will write it here) :
    Replace in ganttproject.sh


    COMMAND_PATH=echo ${0} | sed -e "s/\(.*\)\/.*$/\1/g"
    cd ${COMMAND_PATH}


    with :

    LINK_FILE=$(readlink -f "$0")
    cd dirname $LINK_FILE


    If a user installs the GanttProject into /opt for example and makes link to ~/bin ... those 2 lines will fix the symlink problem.

    Have nice day

     
  • Matthieu Moy
    Matthieu Moy
    2011-03-06

    The solution from paopap works on linux, but "readlink -f" is not as portable as plain "readlink" (AFAIK, it does not work on Mac OS X), so you probably prefer the while loop even if it's a bit longer.

     


Anonymous


Cancel   Add attachments