Wow, thanks for the fast feedback!
My intention was to share a trick for those who need something that works in a fully backward-compatible
way in the short term (like me!).
I agree that the right thing to do is make Groovy work as compatibly as possible across platforms,
so if there's a "script.name" that works on Windows, it should work the same way on Linux too.
The fact that script.name is different between Windows and Linux is a bug on Linux, pure and simple.
It should be fixed ASAP.
Coming up with a new name for this value on Linux to maximize "backward bug compatibility" is
probably misguided because the "script.name" strongly implies it will be the script's name,
not the script engine's name (i.e.: groovy). Hence my vote: fix the bug and minimize confusion
and cruft going forward at the minimal expense of messing up a few bug-dependent scripts today.
If people are super worried, then you could make the installer issue a warning message describing
the problem at install time. At that point, people can just grep their scripts for "script.name".
Personally, I think that's overkill, and might create far more pain than it prevents. Currently, script.name
is pretty much useless on Linux, so how may people actually use it? Not many, I'd guess.
As for Marc G's suggestion, I think it's basically the right one, except that it doesn't quite work
as stated for three reasons:
 You need to pass along $1 not $0 (I'm assuming that was just a typo)
 On Debian at least, whatever value you set for script.name in /usr/bin/groovy gets clobbered on line 18 of /usr/bin/startGroovy
 If you want to cannonicalize the script name's path (which you should), then you need to use readlink
Thus, the best you can do right now (until the fine folks in Groovy land fix the problem) is to modify /usr/bin/startGroovy
and where it once said on line 18 "SCRIPT_PATH="$0" it should say:
if [ "$readLink" == "" ] ; then
SCRIPT_PATH=`readlink -m "$1"`
Why the fancy dance around readlink?
Sadly, Solaris 10 does not ship with it, so in that case the best you can hope for is to limp along w/o cannonicalization.
All of this is just a stopgap though, because Groovy should always try to do the same thing
(i.e.: give you a cannonicalized path) on all platforms. The lack of readline on Solaris 10
means that the ideal solution would probably be to push this logic into Groovy itself, so long
as that won't mess up folks on Cygwin. If people don't care about Solaris 10 much and/or
think those poor souls should just go out and install readlink one fine day, then the startGroovy
script looks like a winner (unless there are meaningful cases where groovy scripts are not
started by startGroovy.... then we're back to pushing the logic into Groovy itself).
For now, the straightforward /usr/bin/startGroovy solution is probably the best one.
What do you all think?