#!/bin/csh

#---------------------------------------------------------------
# 2010-oct-18	C shell script to demo NCL exit problem.
#
# Usage:      ./exit-test.csh < listfile
#
# Where listfile is a file containing one or more text strings
# at least 5 characters long, with no spaces.
#---------------------------------------------------------------

while (1)
   set name = $<		# get next name from standard in
   echo '===========  $name' "= $name"
   
   if ( x$name == x'' ) then		  # stop at end of list
      break
   endif
   
   set name2 = `echo $name | cut -c 5-`	  # compensate for
   if ( x$name2 == x'' ) then		  # unrelated end of file
      echo '*** Illegal name (ignored).'  # bug in C shell on Mac
      break				  # OS 10.5 and earlier
   endif

   ncl exit-test.ncl 'name="'$name'"'
   echo ''
end

echo Done.

