From: Ulrich Drepper Date: Thu, 17 Apr 1997 23:20:34 +0000 (+0000) Subject: Make work even in presence of symlinks. X-Git-Tag: cvs/libc20x-ud-970417~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bae2227b8a3d00296a5587d6c97159fe43b4559;p=thirdparty%2Fglibc.git Make work even in presence of symlinks. --- diff --git a/rellns-sh b/rellns-sh index 5ce265bccf2..e66010d513d 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 , 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%'`