NetBSD/usr.bin/vi/recover/recover.script

47 lines
1.1 KiB
Plaintext
Raw Normal View History

1996-05-20 06:01:36 +04:00
# @(#)recover.script 8.7 (Berkeley) 8/16/94
#
# Script to recover nvi edit sessions.
#
RECDIR=/var/tmp/vi.recover
1996-06-02 08:53:40 +04:00
SENDMAIL=/usr/sbin/sendmail
1996-05-20 06:01:36 +04:00
echo 'Recovering nvi editor sessions.'
# Check editor backup files.
vibackup=`echo $RECDIR/vi.*`
if [ "$vibackup" != "$RECDIR/vi.*" ]; then
for i in $vibackup; do
# Only test files that are readable.
if test ! -r $i; then
continue
fi
# Unmodified nvi editor backup files either have the
# execute bit set or are zero length. Delete them.
if test -x $i -o ! -s $i; then
rm $i
fi
done
fi
# It is possible to get incomplete recovery files, if the editor crashes
# at the right time.
virecovery=`echo $RECDIR/recover.*`
if [ "$virecovery" != "$RECDIR/recover.*" ]; then
for i in $virecovery; do
# Only test files that are readable.
if test ! -r $i; then
continue
fi
# Delete any recovery files that are zero length, corrupted,
# or that have no corresponding backup file. Else send mail
# to the user.
recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
if test -n "$recfile" -a -s "$recfile"; then
$SENDMAIL -t < $i
else
rm $i
fi
done
fi