Просмотр исходного кода

Dpkg::Path: Change find_command() to handle an empty or undef argument

This makes some call sites more natural.
Guillem Jover лет назад: 12
Родитель
Сommit
0c8a23acb4
3 измененных файлов с 10 добавлено и 4 удалено
  1. 1 0
      debian/changelog
  2. 8 3
      scripts/Dpkg/Path.pm
  3. 1 1
      scripts/Dpkg/Source/Package/V2.pm

+ 1 - 0
debian/changelog

@@ -76,6 +76,7 @@ dpkg (1.17.11) UNRELEASED; urgency=low
     - Add new set_as_auto() method to Dpkg::Substvars.
     - Add support for sig and delete_sig spawn() options in Dpkg::IPC.
     - Add %opts to ensure_open() member in Dpkg::Compression::FileHandle.
+    - Change find_command() to handle an empty or undef argument in Dpkg:Path.
   * Mark Format and Installed-Size as automatic substvars in dpkg-genchanges
     and dpkg-gencontrol respectively.
   * Warn on usage of deprecated Source-Version substvar.

+ 8 - 3
scripts/Dpkg/Path.pm

@@ -19,7 +19,7 @@ package Dpkg::Path;
 use strict;
 use warnings;
 
-our $VERSION = '1.03';
+our $VERSION = '1.04';
 
 use Exporter qw(import);
 use File::Spec;
@@ -199,14 +199,15 @@ sub resolve_symlink($) {
 
 =item my $cmdpath = find_command($command)
 
-Return the path of the command if available on an absolute or relative
-path or on the $PATH, undef otherwise.
+Return the path of the command if defined and available on an absolute or
+relative path or on the $PATH, undef otherwise.
 
 =cut
 
 sub find_command($) {
     my $cmd = shift;
 
+    return if not $cmd;
     if ($cmd =~ m{/}) {
 	return "$cmd" if -x "$cmd";
     } else {
@@ -274,6 +275,10 @@ sub find_build_file($) {
 
 =head1 CHANGES
 
+=head2 Version 1.04
+
+Update semantics: find_command() now handles an empty or undef argument.
+
 =head2 Version 1.03
 
 New function: find_build_file()

+ 1 - 1
scripts/Dpkg/Source/Package/V2.pm

@@ -661,7 +661,7 @@ sub do_commit {
     mkpath(File::Spec->catdir($dir, 'debian', 'patches'));
     my $patch = $self->register_patch($dir, $tmpdiff, $patch_name);
     my @editors = ('sensible-editor', $ENV{VISUAL}, $ENV{EDITOR}, 'vi');
-    my $editor = first { defined $_ and find_command($_) } @editors;
+    my $editor = first { find_command($_) } @editors;
     if (not $editor) {
         error(_g('cannot find an editor'));
     }