The following commit has been merged in the master branch:
commit cb674d55c4c7f4983102438f39cec98e8a2d91ce
Author: Guillem Jover <[email protected]>
Date:   Tue Jul 17 04:28:57 2012 +0200

    Switch usage errors to not print entire --help output
    
    Just print a reference to use --help for further details. Which stops
    annoying experienced users, or users that made a typo on the
    command-line, by not overwhelming them with screenfuls of help output.
    
    Closes: #681371

diff --git a/debian/changelog b/debian/changelog
index dd843e7..5e0b06d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -104,6 +104,8 @@ dpkg (1.17.0) UNRELEASED; urgency=low
     gives a correct exit code. Thanks to Bernhard R. Link <[email protected]>.
   * Print correct error message on unknown dpkg-name options before --.
   * Require at least one filename on dpkg-name after --.
+  * Switch program usage errors to not print entire --help output.
+    Closes: #681371
 
   [ Updated programs translations ]
   * Fix typo in Spanish translation of update-alternatives.
diff --git a/scripts/Dpkg/ErrorHandling.pm b/scripts/Dpkg/ErrorHandling.pm
index 88b49ba..3b88534 100644
--- a/scripts/Dpkg/ErrorHandling.pm
+++ b/scripts/Dpkg/ErrorHandling.pm
@@ -97,14 +97,15 @@ sub subprocerr(@)
     }
 }
 
+my $printforhelp = _g('Use --help for program usage information.');
+
 sub usageerr(@)
 {
     my ($msg) = (shift);
 
     $msg = sprintf($msg, @_) if (@_);
     warn "$Dpkg::PROGNAME: $msg\n\n";
-    # XXX: access to main namespace
-    main::usage();
+    warn "$printforhelp\n";
     exit(2);
 }
 
diff --git a/scripts/dpkg-maintscript-helper.sh 
b/scripts/dpkg-maintscript-helper.sh
index 48793b8..6e2252e 100755
--- a/scripts/dpkg-maintscript-helper.sh
+++ b/scripts/dpkg-maintscript-helper.sh
@@ -39,7 +39,7 @@ rm_conffile() {
        fi
        # Skip remaining parameters up to --
        while [ "$1" != "--" -a $# -gt 0 ]; do shift; done
-       [ $# -gt 0 ] || badusage
+       [ $# -gt 0 ] || badusage "missing arguments after --"
        shift
 
        [ -n "$PACKAGE" ] || error "couldn't identify the package"
@@ -142,7 +142,7 @@ mv_conffile() {
        fi
        # Skip remaining parameters up to --
        while [ "$1" != "--" -a $# -gt 0 ]; do shift; done
-       [ $# -gt 0 ] || badusage
+       [ $# -gt 0 ] || badusage "missing arguments after --"
        shift
 
        [ -n "$PACKAGE" ] || error "couldn't identify the package"
@@ -250,7 +250,9 @@ END
 }
 
 badusage() {
-       usage
+       echo "$PROGNAME: error: $1" >&2
+       echo >&2
+       echo "Use '$PROGNAME help' for program usage information." >&2
        exit 1
 }
 
@@ -260,7 +262,7 @@ set -e
 PROGNAME=$(basename $0)
 version="unknown"
 command="$1"
-[ $# -gt 0 ] || badusage
+[ $# -gt 0 ] || badusage "missing command"
 shift
 
 case "$command" in
@@ -301,13 +303,8 @@ mv_conffile)
        END
        ;;
 *)
-       cat >&2 <<-END
-       $PROGNAME: error: command $command is unknown
-       Hint: upgrading dpkg to a newer version might help.
-
-       END
-       usage
-       exit 1
+       badusage "command $command is unknown
+Hint: upgrading dpkg to a newer version might help."
 esac
 
 exit 0
diff --git a/scripts/dpkg-mergechangelogs.pl b/scripts/dpkg-mergechangelogs.pl
index fd6530b..85a53e7 100755
--- a/scripts/dpkg-mergechangelogs.pl
+++ b/scripts/dpkg-mergechangelogs.pl
@@ -85,11 +85,13 @@ my @options_spec = (
 }
 
 my ($old, $new_a, $new_b, $out_file) = @ARGV;
-unless (defined $old and defined $new_a and defined $new_b and
-        -e $old and -e $new_a and -e $new_b)
+unless (defined $old and defined $new_a and defined $new_b)
 {
-    usage();
-    exit(2);
+    usageerr(_g('needs at least three arguments'));
+}
+unless (-e $old and -e $new_a and -e $new_b)
+{
+    usageerr(_g('file arguments need to exist'));
 }
 
 my ($cho, $cha, $chb);
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 1bd0823..d88ded5 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -173,7 +173,9 @@ badusage(char const *fmt, ...)
        vfprintf(stderr, fmt, args);
        va_end(args);
        fprintf(stderr, "\n\n");
-       usage();
+       fprintf(stderr, _("Use '%s --help' for program usage information."),
+               PROGNAME);
+       fprintf(stderr, "\n");
        exit(2);
 }
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to