Package: perltidy
Version: 20180220-1
Control: affects -1 libperl-critic-perl
The attached test program print its own tidied source.
It seems to work correctly:
$ perl selftidy
#!/usr/bin/perl
use Perl::Tidy qw(perltidy);
my $dst;
perltidy( source => $0, destination => \$dst );
print($dst);
But in strace output you can see a spurious filesystem access:
$ strace -o '| grep -w SCALAR >&2' perl selftidy > /dev/null
stat64("SCALAR(0x56bcb8a8)", 0x56bac2b0) = -1 ENOENT (No such file or
directory)
I tracked it down to this code in Perl/Tidy.pm, lines 1278-1291:
# set output file permissions
if ( $output_file && -f $output_file && !-l $output_file ) {
if ($input_file_permissions) {
# give output script same permissions as input script, but
# make it user-writable or else we can't run perltidy again.
# Thus we retain whatever executable flags were set.
if ( $rOpts->{'format'} eq 'tidy' ) {
chmod( $input_file_permissions | oct(600), $output_file );
}
# else use default permissions for html and any other format
}
}
Apparently this is run even when $output_file is a reference, not a
pathname.
-- System Information:
Architecture: i386
Versions of packages perltidy depends on:
ii perl 5.28.1-3
--
Jakub Wilk
#!/usr/bin/perl
use Perl::Tidy qw(perltidy);
my $dst;
perltidy(source => $0, destination => \$dst);
print($dst);