#!/bin/sh
 
#    Jun 30/2000 - F.Majaess

#id  fixstup  - Update setup files.

#    AUTHOR  - F. Majaess

#hd  PURPOSE - "fixstup" script is used to update setup files.
#hd

#pr  PARAMETERS:
#pr 
#pr    POSITIONAL
#pr 
#pr      fn1 fn2 ... fnm = list of m files that require fixing.

#ex  EXAMPLE
#ex  
#ex   fixstup cshrc login
#ex  
#ex   The above example updates .cshrc & .login files 
#ex   in $HOME subdirectory.

# set -x
TmStmp=`date '+%Y%j%H%M%S'`
FESRCGEN='/users/tor/acrn/src/generic'
prmtrl=$@

if [ -d "$FESRCGEN" -a -d "$HOME" ] ; then

#  * Loop over all files in the input list.
for file in $prmtrl
do

 dotfile="$HOME/"".""${file}"
 PLX_file=`echo $file | tr '[a-z]' '[A-Z]'`
 PLX_file="${FESRCGEN}/STANDARD_""${PLX_file}"

  if [ ! -f "$dotfile" ] ; then
#   echo "file ${dotfile} does not exist: resuming execution with next file in list"
    :
  else
    umask 077
    chmod u+w ${dotfile}
    cp -p ${dotfile} ${dotfile}_${TmStmp}_0
    # diff -q ${PLX_file} ${dotfile}_${TmStmp}_0 > /dev/null && \rm -f ${dotfile}_${TmStmp}_0  || \cp ${PLX_file} ${dotfile} 
    diff ${PLX_file} ${dotfile}_${TmStmp}_0 > /dev/null && \rm -f ${dotfile}_${TmStmp}_0  || \cp ${PLX_file} ${dotfile} 
  fi 
done
fi
exit
