Procházet zdrojové kódy

dpkg-name: Require at least one filename after --

This splits the code to first record the arguments to use as filenames,
and then to act on them in a single step, so that we can check if we got
the required filenames.
Guillem Jover před 13 roky
rodič
revize
e43fd15f61
2 změnil soubory, kde provedl 12 přidání a 7 odebrání
  1. 1 0
      debian/changelog
  2. 11 7
      scripts/dpkg-name.pl

+ 1 - 0
debian/changelog

@@ -103,6 +103,7 @@ dpkg (1.17.0) UNRELEASED; urgency=low
   * Move the exit call out from usage() in dpkg-scansources so that usageerr()
     gives a correct exit code. Thanks to Bernhard R. Link <brlink@debian.org>.
   * Print correct error message on unknown dpkg-name options before --.
+  * Require at least one filename on dpkg-name after --.
 
   [ Updated programs translations ]
   * Fix typo in Spanish translation of update-alternatives.

+ 11 - 7
scripts/dpkg-name.pl

@@ -3,7 +3,7 @@
 # dpkg-name
 #
 # Copyright © 1995,1996 Erick Branderhorst <branderh@debian.org>.
-# Copyright © 2006-2010,2012 Guillem Jover <guillem@debian.org>
+# Copyright © 2006-2010,2012-2013 Guillem Jover <guillem@debian.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -215,7 +215,7 @@ sub move($)
     }
 }
 
-@ARGV || usageerr(_g('need at least a filename'));
+my @files;
 
 while (@ARGV) {
     $_ = shift(@ARGV);
@@ -239,15 +239,19 @@ while (@ARGV) {
     } elsif (m/^-a|--no-architecture$/) {
         $options{architecture} = 0;
     } elsif (m/^--$/) {
-        foreach (@ARGV) {
-            move($_);
-        }
-        exit 0;
+        push @files, @ARGV;
+        last;
     } elsif (m/^-/) {
         usageerr(_g("unknown option \`%s'"), $_);
     } else {
-        move($_);
+        push @files, $_;
     }
 }
 
+@files or usageerr(_g('need at least a filename'));
+
+foreach my $file (@files) {
+    move($file);
+}
+
 0;