#!/bin/sh
# 
# relpath -- construct path relative to cwd
# 
# @copyright@
# 
# Author: Ian.Piumarta@INRIA.Fr
# 
# Last edited: Mon Aug 28 08:55:34 2000 by piumarta (Ian Piumarta) on emilia

if test $# -ne 2; then
  echo "usage: $0 srcdir path"
fi

cwd=$1
path=$2

for dir in `echo $cwd | tr '/' ' '`; do
  if expr match $path "/$dir" >/dev/null; then
    path=`echo $path | sed "s,^/$dir,,"`
    cwd=`echo $cwd | sed "s,^/$dir,,"`
  fi
done

path=`echo $path | sed 's,^/,,'`

for dir in `echo $cwd | tr '/' ' '`; do
  path="../$path"
done

echo $path
