]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Mention lzmainfo if trying to use 'lzma --list'.
authorLasse Collin <lasse.collin@tukaani.org>
Tue, 13 Feb 2024 12:32:47 +0000 (14:32 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 14 Feb 2024 16:31:16 +0000 (18:31 +0200)
This kind of fixes the problem reported here:
https://bugs.launchpad.net/ubuntu/+source/xz-utils/+bug/1291020

src/xz/list.c

index 6c1167ba6425ce5aa202f5c9a3859e770ce2fa5d..ca9cf03e85b07f0adfc0a4f9fb4e30ca11bdb9e8 100644 (file)
@@ -1275,10 +1275,22 @@ list_totals(void)
 extern void
 list_file(const char *filename)
 {
-       if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO)
-               message_fatal(_("--list works only on .xz files "
+       if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) {
+               // The 'lzmainfo' message is printed only when --format=lzma
+               // is used (it is implied if using "lzma" as the command
+               // name). Thus instead of using message_fatal(), print
+               // the messages separately and then call tuklib_exit()
+               // like message_fatal() does.
+               message(V_ERROR, _("--list works only on .xz files "
                                "(--format=xz or --format=auto)"));
 
+               if (opt_format == FORMAT_LZMA)
+                       message(V_ERROR,
+                               _("Try 'lzmainfo' with .lzma files."));
+
+               tuklib_exit(E_ERROR, E_ERROR, false);
+       }
+
        message_filename(filename);
 
        if (filename == stdin_filename) {