diff --git a/src/xz/args.c b/src/xz/args.c index e8b07af3..825cf92e 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -786,6 +786,14 @@ args_parse(args_info *args, int argc, char **argv) if (opt_mode != MODE_COMPRESS) message_fatal(_("Decompression support was disabled " "at build time")); +#else + // List mode is only available when decoders are enabled and is + // only valid with .xz files. + if (opt_mode == MODE_LIST + && opt_format != FORMAT_XZ + && opt_format != FORMAT_AUTO) + message_fatal(_("--list works only on .xz files " + "(--format=xz or --format=auto)")); #endif #ifdef HAVE_LZIP_DECODER diff --git a/src/xz/list.c b/src/xz/list.c index 96933760..869b6f79 100644 --- a/src/xz/list.c +++ b/src/xz/list.c @@ -1276,10 +1276,6 @@ 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 " - "(--format=xz or --format=auto)")); - message_filename(filename); if (filename == stdin_filename) {