aboutsummaryrefslogtreecommitdiff
path: root/src/xz/args.c
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2023-01-07 21:55:06 +0800
committerJia Tan <jiat0218@gmail.com>2023-01-21 22:10:51 +0800
commitcc5aa9ab138beeecaee5a1e81197591893ee9ca0 (patch)
treea26ab6b7deb69a6e2a47ea7503191570d34043dc /src/xz/args.c
parentliblzma: Set documentation on all reserved fields to private. (diff)
downloadxz-cc5aa9ab138beeecaee5a1e81197591893ee9ca0.tar.xz
xz: Refactor duplicated check for custom suffix when using --format=raw
Diffstat (limited to 'src/xz/args.c')
-rw-r--r--src/xz/args.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/xz/args.c b/src/xz/args.c
index c31f759a..3468e276 100644
--- a/src/xz/args.c
+++ b/src/xz/args.c
@@ -724,6 +724,14 @@ args_parse(args_info *args, int argc, char **argv)
&& opt_mode != MODE_LIST))
coder_set_compression_settings();
+ // If raw format is used and a custom suffix is not provided,
+ // then only stdout mode can be used when compressing or decompressing.
+ if (opt_format == FORMAT_RAW && suffix_is_set() && !opt_stdout &&
+ (opt_mode == MODE_COMPRESS ||
+ opt_mode == MODE_DECOMPRESS))
+ message_fatal(_("With --format=raw, --suffix=.SUF is "
+ "required unless writing to stdout"));
+
// If no filenames are given, use stdin.
if (argv[optind] == NULL && args->files_name == NULL) {
// We don't modify or free() the "-" constant. The caller