Re: is there a standard for getting a command's version number?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2007-12-22 at 06:52 -0700, Karl Larsen wrote:
>     It is seldom I need the version of software. But when I do it
> seems 
> that --version works all the time. The results are more than you
> wanted 
> but who cares?
> 
> Karl

I assume he he building some automated check to verify version numbers
etc, so he want to avoid having to make special cases (different
parsing) for every single software he is verifying.

You could create a wrapping perl script that is taking the "software" as
an input parameter and then according to a config file (or a hash inside
of the perl script) that will give you the answer you want.

ls.command=ls --version
ls.regexp=ls[^\d]+(\d+\.\d+\S+)\s*
gcc.command=gcc -dumpversion
gcc.regexp=^(\d+\.\d+\S+)\s*

Create a hash based on this, preform a 

if($hash{$software}{'command'} =~ /$hash{$software}{'regexp'}/) {
  print $1;
}

If you aren't familiar with Perl programming, I can create the script
for you, it is a quick task.

/Peter



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux