Re: Kernel-package, fix version 2 ...
[sorry again for line wrapping]
On Mon, October 24, 2005 10:58 am, Sven Luther said:
> On Mon, Oct 24, 2005 at 11:01:53AM +0200, Mattia Dongili wrote:
[...]
>> you could rewrite the grep this way:
>>
>> my @ramdisklist =
>> grep {
>> -x and (
>> system ("$_ --supported-host-version=$hostversion
>> --supported-target-version=$version 1>/dev/null 2>&1") == 0
>> or (
>> (($ramdisk eq "/usr/sbin/mkinitrd") and (system ("dpkg",
>> "--compare-versions", "$version", "lt", "2.6.13") == 0))
>> or
>> (($ramdisk eq "/usr/sbin/mkinitramfs") and (system
>> ("dpkg",
>> "--compare-versions", "$version", "lt", "2.6.12") == 1))
>> or
>> (($ramdisk eq "/usr/sbin/mkinitrd.yaird") and (system
>> ("dpkg", "--compare-versions", "$version", "lt", "2.6.8") ==
>> 1) and (system ("dpkg", "--compare-versions",
>> "$hostversion", "lt", "2.6.8") == 1))
>> )
>> )
>> }
>> (split (/ /, $ramdisk));
>
> Oh, right, altough your code disregard the fact that i need to check for
> two return values of the --supported* case.
oh, I'm just not considering the fact that '$_ --supported-*' can return
other values than just 0 or 1. Is this the case? AFAIR you were talking of
some tool returning 2 in some case, if so please discard my suggestion?
I was just assuming that $ret==0 is ok and any other value is not thus
trying to reduce the case "A or (!A and (...))" :)
> Can i do :
>
> -x and ( my $ret = ...; $ret == 0 or ($ret == 1 and ... ))
>
> or maybe ?
>
> -x and { my $ret = ...; $ret == 0 or ($ret == 1 and ... )}
well, consider that the curly brackets of grep are creating an anonymous
function so you could do all the worst things there :)
Not tested, I'm at work now, but just to give you an idea:
grep
{
my $ret = 0;
if (-x) {
my $supp_host_target = system("$_ --supported... 1>/dev/null 2>&1");
$ret = ($supp_host_target == 0 or ($supp_host_target == 1 and (...)));
}
}
@array;
--
mattia
:wq!
Reply to: