Mercurial > ec-dotfiles
annotate bin/old-cek @ 680:a34ee4c7d0ce
[vimrc] Newer vim seem to have mouse enabled by default?
author | nanaya <me@nanaya.pro> |
---|---|
date | Mon, 13 Jun 2022 00:56:26 +0900 |
parents | 5bafb912837e |
children |
rev | line source |
---|---|
124
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
2 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
3 use warnings; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
4 use strict; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
5 use String::CRC32; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
6 use File::Basename; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
7 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
8 unless($#ARGV+1>0) { |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
9 print("Usage: ", basename($0), " file1 ... fileN\n"); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
10 exit(1); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
11 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
12 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
13 my @files = @ARGV; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
14 #or print("Usage: ", basename($0), " file1 ... fileN\n") && exit(1); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
15 # print usage message if called without arguments |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
16 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
17 foreach (@files) { |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
18 my $filename = $_; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
19 my ($input, $name_checksum, $real_checksum, $checksum); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
20 unless((-r $filename) && (-f $filename)) { |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
21 print(qq("$filename" is not a file or unreadable, skipping\n)); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
22 next(); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
23 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
24 #print(qq(Could not find file "$filename", skipping\n)) and next() unless -r $filename; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
25 #print(qq("$filename" is not a file, skipping\n)) and next() unless -f $filename; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
26 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
27 open(FILE,$filename); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
28 $real_checksum = sprintf("%08X",crc32(*FILE)); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
29 close(FILE); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
30 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
31 if ( /(\[|\()([0-9A-F]{8})(\]|\))/i ) { # does it have a checksum? |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
32 $name_checksum = $2; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
33 if (lc($real_checksum) eq lc($name_checksum)) { |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
34 print("${filename}: $real_checksum - OK!\n"); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
35 next(); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
36 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
37 else { |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
38 print("${filename}: $real_checksum - NOT OK! Should be ${name_checksum}!\n"); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
39 next(); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
40 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
41 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
42 else { # can't find checksum in filename, just print filename + generated checksum and let the user do the thinking |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
43 print("${filename}: $real_checksum\n"); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
44 next(); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
45 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
46 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
47 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
48 exit(0); |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
49 |