#!/bin/csh -f

# If $1 is newer than $2 or $2 is nonexistent, then copy $1 to $2.

set path = (/bin /usr/bin /usr/ucb)
     # avoid running user's programs with overlapping names

if ($#argv != 2) then
  echo "Usage: cpifnewer fromfile tofile"
  exit(1)
endif

if (-e $2) then
    set filetocopy = `find $1 -newer $2 -print`
else
    set filetocopy = $1
endif
if ("$filetocopy" != "") then
    cp $1 $2
else
    echo "cpifnewer: Not copying $1 to newer $2."
endif
