Bug 38761 - error in .sh scripts: symbolic link resolution failure for relative symlinks on the PATH
Summary: error in .sh scripts: symbolic link resolution failure for relative symlinks ...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Unknown (show other bugs)
Version: 5.5.14
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-23 04:41 UTC by Adam Murray
Modified: 2006-03-14 13:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Murray 2006-02-23 04:41:51 UTC
This problem occurs when you have a symbolic link to the tomcat scripts on your
PATH that links to the tomcat script using a relative path.

Steps to reproduce bug:

1. Go to some directory on your PATH. I'm using ~/bin which I've added to my PATH

2. Create a relative symlink to the tomcat statup script. I did: ln -s
../download/tmp/apache-tomcat-5.5.15/bin/catalina.sh start-tomcat

3. Run the symlink. It fails with the following message:
/home/adam/bin/start-tomcat: line 72: cd:
../download/tmp/apache-tomcat-5.5.15/bin/..: No such file or directory
Cannot find /home/adam/bin/setclasspath.sh
This file is needed to run this program


This can be fixed by changing the line:

if expr "$link" : '.*/.*' > /dev/null; then

to:

if expr "$link" : '/.*' > /dev/null; then

in all the .sh scripts. After changing it in catalina.sh, my relative symlink
works correctly. I've tested my fix using a chain of symlinks (both absolute and
relative) that finally resolve to catalina.sh and it seems to work fine.

One of my coworkers pointed out that this same error was in the Maven scripts,
and that they fixed it recently (looks like the same fix I suggested). I imagine
a lot of open source projects are sharing scripts and code, so if you agree that
this is the correct fix someone should check to see if other apache/jakarta
projects need their scripts updated.
Comment 1 Keith Wannamaker 2006-03-14 21:05:24 UTC
Fixed in head, thanks.