diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2018-09-17 15:41:18 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2018-09-17 15:41:18 +0000 |
commit | 4d216fb8ddaea066d730b1daa25f7c7dbaabb232 (patch) | |
tree | 89f6cb3d8ab15e6151a9c61c3d108718281e5275 /usr.bin/vi | |
parent | 02df13c4c551661bbd625dc4d0cd0247b93f37c7 (diff) |
Use the strict pragma for better warnings.
Diffstat (limited to 'usr.bin/vi')
-rw-r--r-- | usr.bin/vi/build/recover | 22 |
1 files 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 = <RECFILE>; + my @recfile = <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. |