From 8280ef193be08a9060f7c5daadb69934d7b7d937 Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 17 Sep 2018 15:41:17 +0000 Subject: [PATCH] Use the strict pragma for better warnings. --- usr.bin/vi/build/recover | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/usr.bin/vi/build/recover b/usr.bin/vi/build/recover index 963542eca25..42f1d7c4ef3 100644 --- a/usr.bin/vi/build/recover +++ b/usr.bin/vi/build/recover @@ -1,14 +1,16 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # -# $OpenBSD: recover,v 1.12 2018/02/03 15:44:36 millert Exp $ +# $OpenBSD: recover,v 1.13 2018/09/17 15:41:17 millert Exp $ # # Script to (safely) recover nvi edit sessions. # +use warnings; +use strict; use Fcntl; -$recoverdir = $ARGV[0] || "/tmp/vi.recover"; -$sendmail = "/usr/sbin/sendmail"; +my $recoverdir = $ARGV[0] || "/tmp/vi.recover"; +my $sendmail = "/usr/sbin/sendmail"; die "Sorry, $0 must be run as root\n" if $>; @@ -38,7 +40,7 @@ if (((stat(_))[2] & 07777) != 01777) { # Check editor backup files. opendir(RECDIR, ".") || die "$0: can't open $recoverdir: $!\n"; -foreach $file (readdir(RECDIR)) { +foreach my $file (readdir(RECDIR)) { next unless $file =~ /^vi\./; # @@ -57,7 +59,7 @@ foreach $file (readdir(RECDIR)) { # at the right time. # rewinddir(RECDIR); -foreach $file (readdir(RECDIR)) { +foreach my $file (readdir(RECDIR)) { next unless $file =~ /^recover\./; if (!sysopen(RECFILE, $file, O_RDONLY|O_NOFOLLOW|O_NONBLOCK)) { @@ -79,7 +81,7 @@ foreach $file (readdir(RECDIR)) { close(RECFILE); next; } - $owner = (stat(_))[4]; + my $owner = (stat(_))[4]; if (! -f _ || ! -s _) { unlink($file) unless -d _; close(RECFILE); @@ -90,14 +92,14 @@ foreach $file (readdir(RECDIR)) { # Slurp in the recover.* file and search for X-vi-recover-path # (which should point to an existing vi.* file). # - @recfile = ; + my @recfile = ; close(RECFILE); # # Delete any recovery files that have no (or more than one) # corresponding backup file. # - @backups = grep(m#^X-vi-recover-path:\s*\Q$recoverdir\E/+#, @recfile); + my @backups = grep(m#^X-vi-recover-path:\s*\Q$recoverdir\E/+#, @recfile); if (@backups != 1) { unlink($file); next; @@ -109,7 +111,7 @@ foreach $file (readdir(RECDIR)) { # references to data in @recfile which we pipe to sendmail. # $backups[0] =~ m#^X-vi-recover-path:\s*\Q$recoverdir\E/+(.*)[\r\n]*$#; - $backup = $1; + my $backup = $1; # # If backup file is not rooted in the recover dir, ignore it. -- 2.20.1