#!/bin/csh
onintr restart
set num = 0
restart:
  set oldnum = $num
  set num = `ls log.* | wc -l`
  if ($num == $oldnum) then
    echo "no new logfile, <exit>?"
    set input = $<
    if ($input == "y") goto end
  endif

    ls log.* > .crafty.watch.tmp
    echo "log file `tail -1 .crafty.watch.tmp`"
    tail -f `tail -1 .crafty.watch.tmp`

end:
    rm .crafty.watch.tmp
