#!/bin/csh -f
#
# fixRelPaths
#
# x-kernel v3.2
#
# Copyright (c) 1991  Arizona Board of Regents
#
# $Revision: 1.2 $
# $Date: 1991/10/09 18:46:44 $
#
# Takes a list of filenames relative to the current
# directory on the input stream and rewrites each name relative to 
# the directory above the current directory.  The name of the current 
# directory in the above directory should be passed on the command line.
#

set dir = $1

# four cases:
#	../foo -- remove the leading ..
#	/foo   -- no change
# 	./foo  -- rewrite as "currentDir/foo"
#	foo    -- rewrite as "currentDir/foo"

awk -F/ '/^\.\.\//	{ print substr($0, 4); next }	\
	 /^\//	    	{ print $0; next }		\
	 /^.\// 	{ print dir"/"substr($0, 3); next }	\
	          	{ print dir"/"$0 }		\
	' dir=$dir -
		

