groovy
  1. groovy
  2. GROOVY-3372

groovy cannot find startGroovy if the groovy executable is a symlink

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.6
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      all *NIX/POSIX
    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      Description

      A lot of people like to create symlinks to executable binaries or scripts. For example, many linux systems use the alternatives system to symlink

      /usr/bin/progname -> /etc/alternatives/progname -> /path/to/progname

      Currently, groovy does not support this option. If I have:

      $ ls -l /home/greg/bin/groovy
      lrwxrwxrwx 1 greg greg 40 2009-02-22 22:49 /home/greg/bin/groovy -> /home/greg/opt/groovy/current/bin/groovy

      And I try to run:

      $ groovy -e 'print("HELLO GROOVY")'

          1. I get:
            .: 28: Can't open /home/greg/bin/startGroovy

      A simple fix would be (adapted from the jruby startup script):
      ------------------------------
      1c1
      < #!/bin/sh

      > #!/bin/ksh
      15a16,29
      > get_dirname()
      >

      { > PRG=$0 > while [ -h "$PRG" ]; do > link=`expr "$(ls -l $PRG)" : '.*-> \(.*\)'` > if expr "$link" : '/' > /dev/null; then > PRG=$link > else > PRG="`dirname $PRG`/$link" > fi > done > echo -n `dirname $PRG` > }

      >
      17c31
      < DIRNAME=`dirname "$0"`

      > DIRNAME=`get_dirname $0`
      --------------------

      The above was tested in bash, dash and pdksh.

      Ideally, the same patch would be applied to groovyc and groovysh as well

        Activity

        Guillaume Laforge made changes -
        Field Original Value New Value
        Fix Version/s 1.6.2 [ 15151 ]
        Fix Version/s 1.6.1 [ 14852 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.6.2 [ 15151 ]
        Fix Version/s 1.6.3 [ 15251 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Fix Version/s 1.6.3 [ 15251 ]
        Guillaume Laforge made changes -
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Fix Version/s 1.7-beta-x [ 15538 ]
        blackdrag blackdrag made changes -
        Fix Version/s 1.8.x [ 15750 ]
        Fix Version/s 2.x [ 17013 ]
        Fix Version/s 1.7.x [ 15538 ]
        Pascal Schumacher made changes -
        Fix Version/s 1.8.x [ 15750 ]
        Fix Version/s 2.x [ 17013 ]
        Component/s command line processing [ 10445 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Greg Orlowski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: