#!/bin/csh -f
#
# fixRelPaths:  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 -
		

