[lintian] 02/03: coll/scripts: Migrate to L::Path API
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit e2044f244eeee4553f6334b4c28ba4e01388d531
Author: Niels Thykier <niels@thykier.net>
Date: Sun Sep 28 20:30:31 2014 +0200
coll/scripts: Migrate to L::Path API
Signed-off-by: Niels Thykier <niels@thykier.net>
---
collection/scripts | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/collection/scripts b/collection/scripts
index 43ca74a..34ddcda 100755
--- a/collection/scripts
+++ b/collection/scripts
@@ -35,8 +35,8 @@ sub collect {
my $scripts_fd; # We lazily open this FD.
foreach my $file ($info->sorted_index) {
- next unless $file->is_regular_file;
- my $scriptpath = shebang_line($info->unpacked($file));
+ next unless $file->is_regular_file and $file->is_open_ok;
+ my $scriptpath = shebang_line($file);
next unless defined($scriptpath); # no shebang line => not a script
@@ -65,32 +65,24 @@ sub collect {
close($scripts_fd) if defined($scripts_fd);
open(my $ctrl_fd, '>', "$dir/control-scripts");
-
- opendir(my $dirfd, "$dir/control");
- for my $file (readdir($dirfd)) {
- next if $file =~ m{\A \. \.? \Z}xsm;
- my $path = $info->control($file);
- my $scriptpath;
-
- next if -l $path or not -f _;
- $scriptpath = shebang_line($path);
+ for my $path ($info->control_index('')->children) {
+ next unless $path->is_open_ok;
+ my $scriptpath = shebang_line($path);
next unless defined($scriptpath);
# Remove everything after the first space (i.e. any options)
$scriptpath =~ s/\s++ .++ \Z//xsm;
- print {$ctrl_fd} "$scriptpath $file\n";
+ print {$ctrl_fd} "$scriptpath $path\n";
}
- closedir($dirfd);
close($ctrl_fd);
return;
}
sub shebang_line {
- my ($filename) = @_;
- my $scriptpath;
- my $magic;
- open(my $fd, '<', $filename);
+ my ($path) = @_;
+ my ($scriptpath, $magic);
+ my $fd = $path->open;
if (read($fd, $magic, 2) and $magic eq '#!' and not eof($fd)) {
$scriptpath = <$fd>;
strip($scriptpath);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: