#!/bin/sh
#
# Add casa:: to the file mentioned in $2.
# It does it by using the sed script mentioned in $1.
# The sed script is as selective as possible, but it might happen that
# comments or quoted strings get changed.
# Therefore suspicious differences are shown,
#
# Run as:
#    dosedns_one <sed-script> <file>


  echo "Execute dosedns_one on $2 ..."
  sed -f $1 $2 > $2.new
  diff $2 $2.new > $2.diff 2>&1
  # Only rename if different, so date only changes if necessary.
  if [ $? != 0 ]; then
    mv $2.new $2
    # See if quoted strings or comments have been changed
    egrep '(".*casa::.*")|//(.*casa::)' $2.diff > /dev/null 2>&1
    sts=$?
    if [ $sts == 0 ]; then
      echo " *** Suspicious changes in $2 ***"
      egrep '(".*casa::.*")|//(.*casa::)' $2.diff
    fi
  else
    \rm -f $2.new
  fi
  \rm -f $2.diff
