db: avoid use of errno field name
[nvi.git] / dist / recover.in
blob8b87a6b4d1bbe2bc561a6ba6d71d1b5d4d07ab11
1 #!/bin/sh -
3 # $Id: recover.in,v 8.9 2001/08/30 13:59:23 skimo Exp $ (Berkeley) $Date: 2001/08/30 13:59:23 $
5 # Script to recover nvi edit sessions.
7 RECDIR="@vi_cv_path_preserve@"
8 SENDMAIL="@vi_cv_path_sendmail@"
10 echo 'Recovering nvi editor sessions.'
12 # Check editor backup files.
13 vibackup=`echo $RECDIR/vi.*`
14 if [ "$vibackup" != "$RECDIR/vi.*" ]; then
15 for i in $vibackup; do
16 # Only test files that are readable.
17 if test ! -r $i; then
18 continue
21 INUSE="@INUSE@"
22 if test "$INUSE" && $INUSE; then
23 continue
26 # Unmodified nvi editor backup files either have the
27 # execute bit set or are zero length. Delete them.
28 if test -x $i -o ! -s $i; then
29 rm $i
31 done
34 # It is possible to get incomplete recovery files, if the editor crashes
35 # at the right time.
36 virecovery=`echo $RECDIR/recover.*`
37 if [ "$virecovery" != "$RECDIR/recover.*" ]; then
38 for i in $virecovery; do
39 # Only test files that are readable.
40 if test ! -r $i; then
41 continue
44 INUSE="@INUSE@"
45 if test "$INUSE" && $INUSE; then
46 continue
49 # Delete any recovery files that are zero length, corrupted,
50 # or that have no corresponding backup file. Else send mail
51 # to the user.
52 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
53 if test -n "$recfile" -a -s "$recfile"; then
54 $SENDMAIL -t < $i
55 else
56 rm $i
58 done