#!/bin/csh
#
# Check out each $* that is writable but not locked
# and preserve the current writable file.  I use this sometimes because
# rdist does not update file permissions if only file permissions changed.
# This happens when I check in a file under RCS at work and then rdist
# it to home.  Then I edit it at home and don't realize I need to check
# it out from RCS because it is writable.  Then I rdist back to work.
# So I end up modifying files without checking them out.
#
# The real problem is that rdist does not update permissions on files
# unless the file has changed.  I can probably ask RCS to touch the file
# when it is checked in to avoid this.
#

foreach file ($*)
  if (-w $file) then
    set lock = `rlog -L -R $file`
    if ($lock == '') then
	echo $file
    endif
  endif
end

foreach file ($*)
  if (-w $file) then
    set lock = `rlog -L -R $file`
    if ($lock == '') then
	\mv -f $file $file.tmp
	co -l $file
	\mv -f $file.tmp $file
    endif
  endif
end
