#!/bin/csh -f # cprelsafe # ------------------------------------------------------------------------------ # Shell script to copy a file to the same relative location in a target # directory. Basically appends entire 1st arg to 2nd arg to determine # target location. Creates nested target directories as needed. # Silently does nothing if the specified file is a directory or a socket, # which would otherwise have returned an error. # ------------------------------------------------------------------------------ # Usage: See Usage section below or run with no arguments to see usage. # Assumptions: # Effects: # - Copies a file and creates containing target dirs. # Notes: # Implementation Notes: # Portability Issues: # Revision History: # $Log$ # ------------------------------------------------------------------------------ set option = if ("$1" == "-i") then set option = "$1" shift endif if ($#argv < 2) then echo "Usage: $0:t [-i] source_filename target_dir_root" echo "Example: $0:t abc target abc --> target/abc" echo "Example: $0:t ./abc target ./abc --> target/./abc" echo "Example: $0:t ../abc target ../abc --> target/../abc" echo "Example: $0:t 1/2/3/abc target 1/2/3/abc --> target/1/2/3/abc" echo "Example: $0:t ~fred/abc target /Users/fred/abc --> /Users/fred/abc" exit 1 endif set rc = 0 if (! -d "$1" && ! -S "$1") then # Execute cprel with all incoming args, including $option which may have # been removed from the $* list by shift. # :q = Quote each incoming arg in case it contains embedded spaces and such. # Use :q instead of "" in case option is empty. Generates nothing instead of # an empty quoted string which would be counted as first arg. cprel $option:q $*:q set rc = $status endif #echo "$rc reported by cprel" exit $rc