#!/bin/sh
# AIM Suite 6/7/9 SAVE
# Copyright (c) 1996 - 2001 Caldera International, Inc.
# All Rights Reserved.
#
# ' @(#) SAVE:1.3 1/22/96 00:00:00'
#
# First, figure out how to make echo work without automatic newline
NNL=
CCL=
if echo "\c" | grep c >/dev/null 2>&1
then
	NNL='-n'
else
	CCL='\c'
fi

# Now do all the saving:

echo Here are the Makefile changes:
diff Makefile Makefile.orig
echo "|||||||||||||||||||||||||||||||||||||||||"

if [ -f config ]
then
	echo
	echo Here is the config file:
	cat config
	echo "|||||||||||||||||||||||||||||||||||||||||"
fi

if [ -f workfile ]
then
	echo
	echo Here is the workfile:
	cat workfile
	echo "|||||||||||||||||||||||||||||||||||||||||"
elif [ -f s9workfile ]
then
	echo
	echo Here is the s9workfile:
	cat s9workfile
	echo "|||||||||||||||||||||||||||||||||||||||||"
fi

echo
echo Here is the nohup.out file:
cat nohup.out 
echo "|||||||||||||||||||||||||||||||||||||||||"

if [ -f ../nohup.out ]
then
	echo
	echo Here is the top level nohup.out file:
	cat ../nohup.out
	echo "|||||||||||||||||||||||||||||||||||||||||"
fi

echo
echo Here are the binary file sizes:
if [ -f multitask ]
then
	size *.o multitask
elif [ -f singleuser ]
then
	size *.o singleuser
fi
echo "|||||||||||||||||||||||||||||||||||||||||"

for i in *.c *.h
do
	FILES=`ls $i* | wc -l`
	if [ $FILES -gt 1 ]  # there are other copies of the source file
	then
	    for j in $i*
	    do
		if [ $i = $j ]
		then
			continue
		fi
		echo
		echo $NNL "Save the diff between $i and $j (y/n) ? [y] $CCL: "
		read ANS
		case "$ANS" in
		    ""|y|Y|yes|YES)	echo
					echo Diff between $i and $j:
					diff $i $j 
					echo "|||||||||||||||||||||||||||||||||||||||||" ;;
		esac
	    done
	fi
done

echo
echo
AIMID=`ls ../#* 2> /dev/null | wc -l`
if [ $AIMID -eq 1 ]  # here is aimid#, is it correct?
then
	echo $NNL "Enter the AIM id [`cd ..; ls \#*`] :$CCL"
	read ANS
	if [ "$ANS" != "" ]
	then
	    ANS=`echo $ANS | sed "s/^#//"`    # make sure safe to add # sign
	    touch ../\#$ANS
	    echo AIM id \# is : \#$ANS
	else
	    echo AIM id \# is : `cd ..; ls \#*`
	fi
else
	echo $NNL "Enter the AIM id :$CCL"
	read ANS
	ANS=`echo $ANS | sed "s/^#//"`        # make sure safe to add # sign
	touch ../\#$ANS
	echo AIM id \# is : \#$ANS
fi

echo
echo
echo "******************************"
echo "REMEMBER TO SAVE README FILES." 
echo
echo "******************************"
echo
