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

dpkg: Use badusage() instead of ohshit() for command-line errors

Guillem Jover лет назад: 11
Родитель
Сommit
3a5e0d6cd9
3 измененных файлов с 7 добавлено и 6 удалено
  1. 1 0
      debian/changelog
  2. 2 2
      dpkg-deb/main.c
  3. 4 4
      src/trigcmd.c

+ 1 - 0
debian/changelog

@@ -51,6 +51,7 @@ dpkg (1.18.0) UNRELEASED; urgency=low
   * Make dependency checks fatal for dpkg-buildpackage -S.
   * Update amd64 GNU cpu regex in cputable to match amd64 too, in addition
     to x86_64. This is required for FreeBSD.
+  * Use badusage() instead of ohshit() for command-line errors.
 
   * Perl modules:
     - Rename and deprecate Dpkg::Gettext _g function with new g_.

+ 2 - 2
dpkg-deb/main.c

@@ -204,7 +204,7 @@ set_compress_strategy(const struct cmdinfo *cip, const char *value)
 {
   compress_params.strategy = compressor_get_strategy(value);
   if (compress_params.strategy == COMPRESSOR_STRATEGY_UNKNOWN)
-    ohshit(_("unknown compression strategy '%s'!"), value);
+    badusage(_("unknown compression strategy '%s'!"), value);
 }
 
 static void
@@ -212,7 +212,7 @@ set_compress_type(const struct cmdinfo *cip, const char *value)
 {
   compress_params.type = compressor_find_by_name(value);
   if (compress_params.type == COMPRESSOR_TYPE_UNKNOWN)
-    ohshit(_("unknown compression type '%s'!"), value);
+    badusage(_("unknown compression type '%s'!"), value);
   if (compress_params.type == COMPRESSOR_TYPE_LZMA)
     warning(_("deprecated compression type '%s'; use xz instead"), value);
   if (compress_params.type == COMPRESSOR_TYPE_BZIP2)

+ 4 - 4
src/trigcmd.c

@@ -120,8 +120,8 @@ parse_awaiter_package(void)
 		pkgname = getenv("DPKG_MAINTSCRIPT_PACKAGE");
 		archname = getenv("DPKG_MAINTSCRIPT_ARCH");
 		if (pkgname == NULL || archname == NULL)
-			ohshit(_("must be called from a maintainer script"
-			         " (or with a --by-package option)"));
+			badusage(_("must be called from a maintainer script"
+			           " (or with a --by-package option)"));
 
 		pkg = pkg_spec_find_pkg(pkgname, archname, &err);
 	} else if (strcmp(bypackage, "-") == 0) {
@@ -226,8 +226,8 @@ main(int argc, const char *const *argv)
 
 	badname = parse_awaiter_package();
 	if (badname)
-		ohshit(_("illegal awaited package name '%.250s': %.250s"),
-		       bypackage, badname);
+		badusage(_("illegal awaited package name '%.250s': %.250s"),
+		         bypackage, badname);
 
 	activate = argv[0];
 	badname = trig_name_is_illegal(activate);