mirror of
https://github.com/BishopFox/theos-jailed.git
synced 2026-11-07 10:25:57 -10:00
[bin] Add a simple script for version number comparisons.
git-svn-id: http://svn.howett.net/svn/theos/trunk@378 4410221e-0ddf-4ce3-99c0-2db6c0dbc727
This commit is contained in:
1 parent
e02eadcdf5
commit
fcb9c03610
1 file changed
+23
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
if(@ARGV < 3) {
|
||||
exit 1;
|
||||
}
|
||||
my @afirst = split(/\./, $ARGV[0]);
|
||||
my $op = $ARGV[1];
|
||||
my @asecond = split(/\./, $ARGV[2]);
|
||||
|
||||
push(@afirst, 0) while(@afirst < @asecond);
|
||||
push(@asecond, 0) while(@asecond < @afirst);
|
||||
|
||||
my $v1 = 0;
|
||||
my $v2 = 0;
|
||||
map { ($v1 *= 100) += $_ } (@afirst);
|
||||
map { ($v2 *= 100) += $_ } (@asecond);
|
||||
|
||||
print "1" if $v1 > $v2 && $op eq "gt";
|
||||
print "1" if $v1 < $v2 && $op eq "lt";
|
||||
print "1" if $v1 >= $v2 && $op eq "ge";
|
||||
print "1" if $v1 <= $v2 && $op eq "le";
|
||||
print "1" if $v1 == $v2 && $op eq "eq";
|
||||
Reference in new issue
Block a user