Subject: nvi recovery
To: None <tech-userlevel@netbsd.org>
From: matthew green <mrg@eterna.com.au>
List: tech-userlevel
Date: 01/13/1999 00:04:43
i'd like to replace this code snippet in /etc/rc with the
one distributed with nvi:
virecovery=`echo /var/tmp/vi.recover/recover.*`
if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
echo preserving editor files
for i in $virecovery; do
sendmail -t < $i
done
fi
with the below script (from src/usr.bin/vi/recover/recover.script)
either embeded in /etc/rc, or as a separate file (i don't care).
it adds these features:
- get rid of certain non-recover files
- non readable backup files
- non readable recover files
- unmodified backup files
- only send mail about files that have a valid
X-vi-recover-path: header, deleting others.
i'm tempted to feel that we should delete the recover files after
they have been mailed once in any case so that the user is not
sent multiple messages.
comments?
# @(#)recover.script 8.7 (Berkeley) 8/16/94
#
# Script to recover nvi edit sessions.
#
RECDIR=/var/tmp/vi.recover
SENDMAIL=/usr/sbin/sendmail
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