Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3372

groovy cannot find startGroovy if the groovy executable is a symlink

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.6
    • None
    • None
    • all *NIX/POSIX
    • Patch

    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

      Attachments

        Activity

          People

            Unassigned Unassigned
            gorlowski Greg Orlowski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: