Menu

#157 bash startup scripts fail when symbolically linked to

v5.0
closed
startup (1)
6
2014-08-21
2014-08-06
No

I am checking the version 5-beta-2 and wanted to add symbolic links in my path.
However proguardgui.sh fails to start in a different directory because PROGUARD_HOME gets the directory from symbolic link rather than script.

The fix is to replace the following line:
PROGUARD_HOME=dirname "$0"/..

into this:
PROGUARD_HOME=$(dirname "$(readlink -e $0)")/..

This way it follows the link (if any) and correctly detects the PROGUARD_HOME.

Discussion

  • Eric Lafortune

    Eric Lafortune - 2014-08-06

    Solaris doesn't have "readlink", and Mac OS X doesn't have "readlink -e" by default, so I've held off on using it. I currently have the following for the upcoming ProGuard 5.0 beta3, hoping that it is sufficiently portable:

    PROGUARD=`readlink -f "$0" 2>/dev/null`
    if test "$PROGUARD" = ''
    then
      PROGUARD=`readlink "$0" 2>/dev/null`
      if test "$PROGUARD" = ''
      then
        PROGUARD="$0"
      fi
    fi
    
    PROGUARD_HOME=`dirname "$PROGUARD"`/..
    
     

    Last edit: Eric Lafortune 2014-08-06
  • Eric Lafortune

    Eric Lafortune - 2014-08-06
    • status: open --> accepted
    • Priority: 5 --> 6
     
  • Eric Lafortune

    Eric Lafortune - 2014-08-20
    • status: accepted --> closed
     
  • Eric Lafortune

    Eric Lafortune - 2014-08-21
    • Group: Some sunny day --> v5.0
     

Log in to post a comment.