+&checkcommandversion
[macros.git] / AutoGen.pm
index 4bbb8fd..cad8cbf 100644 (file)
@@ -38,7 +38,6 @@ BEGIN {
                use File::chdir;        # $CWD
                use File::Touch;        # &touch
                use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG);
                use File::chdir;        # $CWD
                use File::Touch;        # &touch
                use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG);
-               use File::Glob qw(:glob);       # &bsd_glob, &GLOB_*
 HERE
                eval "$_\n; 1;" or push @missing,(/^\s*use\s+([^ ;]+)/)[0];
                }
 HERE
                eval "$_\n; 1;" or push @missing,(/^\s*use\s+([^ ;]+)/)[0];
                }
@@ -64,6 +63,23 @@ Supported parameters:
 '.($Options{"help"} || "");
 }
 
 '.($Options{"help"} || "");
 }
 
+sub checkcommandversion
+{
+my($class,$command,$version)=@_;
+
+       local *F;
+       do { open F,$_ or confess "Open $_: $!"; } for ("$command --version|");
+       local $/;
+       undef $/;
+       my $command_out=<F>;
+       close F;
+       my $command_version=($command_out=~m#([\d.]+)#)[0];
+       confess "$command(1) version not found in its output" if !$command_version;
+       confess "'$command' version $version or higher required"
+                       # Do not take 3rd+ numbers as it would not be a number
+                       if ($command_version=~/^(\d+[.]\d+)/)[0]<$version;
+}
+
 sub _readfile
 {
 my($filename)=@_;
 sub _readfile
 {
 my($filename)=@_;
@@ -122,8 +138,7 @@ my(@files)=@_;
        my $nocheck=shift @files if $files[0] eq "nocheck";
        my $dest=pop @files;
        # expand pattern to properly match &copy resulting filenames count
        my $nocheck=shift @files if $files[0] eq "nocheck";
        my $dest=pop @files;
        # expand pattern to properly match &copy resulting filenames count
-       @files=map({ bsd_glob $_,&GLOB_ERR|&GLOB_NOSORT; } @files);
-       confess "$!" if $File::Glob::GLOB_ERROR;
+       @files=map({ glob $_; } @files);
        @files==copy @files,$dest or $nocheck or confess "$!";
 }
 
        @files==copy @files,$dest or $nocheck or confess "$!";
 }
 
@@ -134,9 +149,8 @@ my(@files)=@_;
 
        my $nocheck=shift @files if $files[0] eq "nocheck";
        my $flag=shift @files if ref $files[0];
 
        my $nocheck=shift @files if $files[0] eq "nocheck";
        my $flag=shift @files if ref $files[0];
-       # expand pattern to properly match &copy resulting filenames count
-       @files=map({ bsd_glob $_,&GLOB_ERR|&GLOB_NOSORT; } @files);
-       confess "$!" if $File::Glob::GLOB_ERROR;
+       # expand pattern to properly match &remove resulting filenames count
+       @files=map({ glob $_; } @files);
        @files==remove((!$flag ? () : $flag),@files) or $nocheck or confess "$!";
 }
 
        @files==remove((!$flag ? () : $flag),@files) or $nocheck or confess "$!";
 }