#!/bin/csh
# create a text file archive in the Smith format
# usage: archive filename...
# output to stdout
# output format: each file is preceded by a header line in the form '@@ filename @@'
# version 1: file cannot include any line starting with '@@' (not checked)
# version 2: escape any leading '@' character to remove restriction
#   @@ filename1 @@
#   line 1 of file 1
#   line 2 of file 1
#   ...
#   last line of file 1
#   @@ filename2 @@
#   line 1 of file 2
#   line 2 of file 2
#   ...
#   last line of file 2
#   (end of file)
#
foreach f ($*)
  echo "@@ $f @@"
  grep '^@@' $f > /dev/null
  if ( ! $status ) then
     # warning message to stderr (use sh to workaround inadequacy of csh)
      echo "echo WARNING: file $f contains possible archive header lines - skipped" '>&2' |sh;
  else 
     cat $f
  endif
end

