[jboss-dev] Symlinks and JBoss AS ./bin/*.sh scripts

Emmanuel Bernard emmanuel at hibernate.org
Sun Nov 28 11:18:16 EST 2010


Hey guys,
Over the week-end I've packaged JBoss AS 6 into HomeBrew (a Mac OS X packaging system made of git and ruby).
I've discovered that our scripts are not symlinks friendly and will fail (often not finding the jars).

I've fixed the issue but I wanted to get a review of my work. Let me know if you thing there could be a problem, otherwise I'll apply them to SVN.

I've basically replaced 

DIRNAME=`dirname $0` 
PROGNAME=`basename $0` 

with

# Extract the directory and the program name 
# takes care of symlinks 
PRG="$0" 
while [ -h "$PRG" ] ; do 
  ls=`ls -ld "$PRG"` 
  link=`expr "$ls" : '.*-> \(.*\)$'` 
  if expr "$link" : '/.*' > /dev/null; then 
    PRG="$link" 
  else 
    PRG="`dirname "$PRG"`/$link" 
  fi 
done 
DIRNAME=`dirname "$PRG"` 
PROGNAME=`basename "$PRG"` 

Full details and full patch available here https://jira.jboss.org/browse/JBAS-8670

Emmanuel


More information about the jboss-development mailing list