]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Make work even in presence of symlinks.
authorUlrich Drepper <drepper@redhat.com>
Thu, 17 Apr 1997 23:20:34 +0000 (23:20 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 17 Apr 1997 23:20:34 +0000 (23:20 +0000)
rellns-sh

index 5ce265bccf2d572b9714ac395cba3dc2892a99b4..e66010d513d64f3a34098de09aa2f6de8e016325 100755 (executable)
--- 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%'`