#!/bin/sh
#
#    Shell script to handle shadow file prompting.

pdir=$1
vers=$2
oldscript=$3
sname=$4

if [ .$CMDDIR = . ]; then
   if [ -f $ITMPDIR/CommandDir ]; then
      CMDDIR=`cat $ITMPDIR/CommandDir`
   fi
fi

if [ .$pdir = .$CMDDIR ]; then
   printm OverwriteCommand $sname $pdir
   curans="x"
   while [ ".$curans" != ".o" -a ".$curans" != ".r" ]; do
      promptname=OverwriteCommand; defanswer="o"; . printp
   done
   if [ ".$curans" = ".r" ]; then
      curans=""
      echo
      while [ ".$curans" = "." ]; do
          promptname=NewFile; defanswer="$vers"; . printp
      done
      if [ "$oldscript" != "$pdir/$curans" ]; then
         cat $oldscript > $pdir/$curans
         chmod 755 $pdir/$curans
         rm -f $oldscript
      fi
   fi
else
   printm ShadowWarning $sname $pdir 
   curans="x"
   while [ ".$curans" != ".c" -a ".$curans" != ".r" ]; do
      promptname=ShadowWarning; defanswer="r"; . printp
   done
   if [ ."$curans" = ."r" ]; then
      curans=""
      echo
      while [ ".$curans" = "." ]; do
          promptname=NewFile; defanswer="$vers"; . printp
      done
      if [ "$oldscript" != "$pdir/$curans" ]; then
         cat $oldscript > $pdir/$curans
         chmod 755 $pdir/$curans
         rm -f $oldscript
      fi
   fi
fi
