summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-04-17 23:20:34 +0000
committerUlrich Drepper <drepper@redhat.com>1997-04-17 23:20:34 +0000
commit5bae2227b8a3d00296a5587d6c97159fe43b4559 (patch)
treeb7acf5befb1ff68eb73fa109a462a04c5fafeb62
parent5703aac7bebfc3a92d5a8c211be1fe7873d3f132 (diff)
Make work even in presence of symlinks.
-rwxr-xr-xrellns-sh46
1 files changed, 20 insertions, 26 deletions
diff --git a/rellns-sh b/rellns-sh
index 5ce265bccf..e66010d513 100755
--- a/rellns-sh
+++ b/rellns-sh
@@ -1,6 +1,6 @@
#! /bin/sh
# rellns-sh - Simplified ln program to generate relative symbolic link.
-# Copyright (C) 1996 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
# Written by Ulrich Drepper <drepper@cygnus.com>, October 1996
#
# This program is free software; you can redistribute it and/or modify
@@ -22,33 +22,27 @@ if test $# -ne 2; then
exit 1
fi
-case $1 in
-/*)
- # Make both paths absolute.
- to=`echo $1 | sed 's%^/%%'`
-
- if test -d $2; then
- from=`echo $2 | sed 's%/*$%%'`
- else
- from=`echo $2 | sed 's%/*[^/]*$%%'`
- fi
+# Make both paths absolute.
+if test -d $1; then
+ to=`cd $1 && /bin/pwd`
+else
+ temp=`echo $1 | sed 's%/*[^/]*$%%'`
+ to=`cd $temp && /bin/pwd`
+ to="$to/`echo $1 | sed 's%.*/\([^/][^/]*\)$%\1%'`"
+fi
+to=`echo $to | sed 's%^/%%'`
- case "$from" in
- /*) from=`echo $from | sed 's%^/*%%'` ;;
- ?*) from=`cd $from && pwd | sed 's%^/%%'` ;;
- *) from=`pwd | sed 's%^/%%'` ;;
- esac
- ;;
-*)
- to=$1
+if test -d $2; then
+ from=`echo $2 | sed 's%/*$%%'`
+else
+ from=`echo $2 | sed 's%/*[^/]*$%%'`
+fi
- if test -d $2; then
- from=`echo $2 | sed 's%/*$%%'`
- else
- from=`echo $2 | sed 's%/*[^/]*$%%'`
- fi
- ;;
-esac
+if test -z "$from"; then
+ from=`/bin/pwd | sed 's%^/%%'`
+else
+ from=`cd $from && /bin/pwd | sed 's%^/%%'`
+fi
while test -n "$to" && test -n "$from"; do
preto=`echo $to | sed 's%^\([^/]*\)/.*%\1%'`