Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 31 lines (24 sloc) 1.052 kb
830d376 @feeley Add relpath file which had been deleted by error in a previous change.
authored
1 #! /bin/sh
2
3 # Conversion of an absolute path to a relative path.
4
5 # Copyright (c) 2008 by Marc Feeley, All Rights Reserved.
6
7 TARGET_PATH=`echo "$1" | sed -e 's#\\\\#/#g' -e 's#//*#/#g' -e 's#/$##' -e 's#\([/]\{0,1\}\)\(.*\)#\2/#' -e 's#^/$##'`
8 ORIG_DIR=`echo "$2" | sed -e 's#\\\\#/#g' -e 's#//*#/#g' -e 's#/$##' -e 's#\([/]\{0,1\}\)\(.*\)#\2/#' -e 's#^/$##'`
9 ENABLE_MV="$3"
10
11 while test "$TARGET_PATH" != "" -a "$ORIG_DIR" != ""; do
12 TP_CAR=`echo "$TARGET_PATH" | sed -e 's#\([^/]*[/]\)\(.*\)#\1#'`
13 TP_CDR=`echo "$TARGET_PATH" | sed -e 's#\([^/]*[/]\)\(.*\)#\2#'`
14 OD_CAR=`echo "$ORIG_DIR" | sed -e 's#\([^/]*[/]\)\(.*\)#\1#'`
15 OD_CDR=`echo "$ORIG_DIR" | sed -e 's#\([^/]*[/]\)\(.*\)#\2#'`
16 if test "$TP_CAR" = "$OD_CAR"; then
17 TARGET_PATH="$TP_CDR"
18 ORIG_DIR="$OD_CDR"
19 else
20 break
21 fi
22 done
23
24 REL_PATH=`echo "$ORIG_DIR" | sed -e 's#[^/]*[/]#../#g'`"$TARGET_PATH"
25
26 if test "$ENABLE_MV" = "yes"; then
27 echo "$REL_PATH" | sed -e 's#^#/#' -e 's#^\(.*/\)\([^/][^/]*\)/\([^/][^/]*\)/$#\1current/\3/#' -e 's#^/##'
28 else
29 echo "$REL_PATH"
30 fi
Something went wrong with that request. Please try again.