[Users] [Bug 4139] New: Clawsker broken with perl 5.22+

H.Merijn Brand h.m.brand at xs4all.nl
Fri Dec 21 21:51:09 CET 2018


On Fri, 21 Dec 2018 21:46:07 +0100, "H.Merijn Brand"
<h.m.brand at xs4all.nl> wrote:

> but the root cause is in the qx// if/when the full path to claws-mail
> contains a space. The code makes it really hard to debug, as $_ is
> abused and altered, so you cannot show the full path on failure. Here
> is a safe version:
> 
> sub get_claws_version {
>     my $cm_path = which ('claws-mail') or return ""; # not found
>     open my $ph, "-|", $cm_path, "-v"  or return ""; # no pipe
>     chomp (my $v = <$ph>);
>     close $ph;
>     # Claws Mail version 3.17.2git17
>     $v =~ m/\bversion\s+(\d[\w.]+)/ or die "Invalid version string:
> '$v'"; my $cmv = $1;
>     my @ver = split m/\./ => $cmv;
>     my $res = "$ver[0].$ver[1].";
>     return $res . ($ver[3] =~ m/(\d+)git(\d+)/ ? "$1.$2" :
> "$ver[2].0"; }

Now simpler and without syntax error:

sub get_claws_version {
    my $cm_path = which ('claws-mail') or return ""; # not found
    open my $ph, "-|", $cm_path, "-v"  or return ""; # no pipe
    chomp (my $v = <$ph>);
    close $ph;
    # Claws Mail version 3.17.2git17
    $v =~ m/\bversion\s+(\d[\w.]+)/ or die "Invalid version string: '$v'";
    my $cmv = $1;
    my @ver = split m/(?:\.|git)/ => $cmv;
    @ver < 4 and push @ver, 0;
    return join "." => @ver;
    }


-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.29   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.claws-mail.org/pipermail/users/attachments/20181221/cc97dec5/attachment.sig>


More information about the Users mailing list