summaryrefslogtreecommitdiff
path: root/usr.bin/vi/build
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-01-11 04:56:53 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-01-11 04:56:53 +0000
commit8dd63d6ea6486316f99d93595571e08790e27627 (patch)
treecbec1f39af1a625ae519d87af1b8afa2b250003e /usr.bin/vi/build
parent59272e169bcf88ada549101398f7a1e920cd0406 (diff)
grep() returns a list of aliases to entries in the original list
so modifying them directly results in a munged line in the resulting mail message that gets sent out. Similar to a patch from cazz@wezl.org; closes PR 1617
Diffstat (limited to 'usr.bin/vi/build')
-rw-r--r--usr.bin/vi/build/recover23
1 files changed, 14 insertions, 9 deletions
diff --git a/usr.bin/vi/build/recover b/usr.bin/vi/build/recover
index 00bbb001af8..f5230936f6d 100644
--- a/usr.bin/vi/build/recover
+++ b/usr.bin/vi/build/recover
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# $OpenBSD: recover,v 1.6 2000/04/21 17:06:13 millert Exp $
+# $OpenBSD: recover,v 1.7 2001/01/11 04:56:52 millert Exp $
#
# Script to (safely) recover nvi edit sessions.
#
@@ -90,17 +90,22 @@ foreach $file (readdir(RECDIR)) {
#
@recfile = <RECFILE>;
close(RECFILE);
- @backups = grep(s/^X-vi-recover-path:\s*(.*)[\r\n]*$/$1/, @recfile);
#
- # Delete any recovery files that are zero length, corrupted,
- # or that have no corresponding backup file. Else send mail
- # to the user.
+ # Delete any recovery files that have no (or more than one)
+ # corresponding backup file.
#
- if ($#backups != 0) {
- unlink($file);
- } elsif (! -s $backups[0]) {
- unlink($file, $backups[0]);
+ @backups = grep(/^X-vi-recover-path:/, @recfile);
+ unlink($file) unless $#backups == 0;
+
+ #
+ # If recovery file is zero length, remove it.
+ # Else send mail to the user.
+ #
+ $backups[0] =~ /^X-vi-recover-path:\s*(.*)[\r\n]*$/;
+ $backup = $1;
+ if (! -s $backup) {
+ unlink($file, $backup);
} else {
open(SENDMAIL, "|$sendmail -t") ||
die "$0: can't run $sendmail -t: $!\n";