summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2017-03-23 03:48:51 (GMT)
committerDmitry V. Levin <ldv@altlinux.org>2017-03-23 03:48:51 (GMT)
commitb1daffc4e5653f05fa6a7eb40d0751c300837636 (patch)
treec201e77fa3d006d18b4ddee3e277b044f6a1e78d /programs
parenteff6166eb84a7aca764cf310bc9eef23d003c354 (diff)
downloadlz4-b1daffc4e5653f05fa6a7eb40d0751c300837636.zip
lz4-b1daffc4e5653f05fa6a7eb40d0751c300837636.tar.gz
lz4-b1daffc4e5653f05fa6a7eb40d0751c300837636.tar.bz2
cli: add GNU separator -- specifying that all following arguments are files
This option is supported by other compressors with compatible cli, so add it to lz4 as well for better compatibility.
Diffstat (limited to 'programs')
-rw-r--r--programs/lz4.1.md3
-rw-r--r--programs/lz4cli.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/programs/lz4.1.md b/programs/lz4.1.md
index 48f3152..6f42904 100644
--- a/programs/lz4.1.md
+++ b/programs/lz4.1.md
@@ -194,6 +194,9 @@ only the latest one will be applied.
* `--rm` :
Delete source files on successful compression or decompression
+* `--` :
+ Treat all subsequent arguments as files
+
### Benchmark mode
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index 0578bde..7a75f55 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -271,6 +271,7 @@ int main(int argc, const char** argv)
forceStdout=0,
main_pause=0,
multiple_inputs=0,
+ all_arguments_are_files=0,
operationResult=0;
operationMode_e mode = om_auto;
const char* input_filename = NULL;
@@ -315,7 +316,7 @@ int main(int argc, const char** argv)
if(!argument) continue; /* Protection if argument empty */
/* Short commands (note : aggregated short commands are allowed) */
- if (argument[0]=='-') {
+ if (!all_arguments_are_files && argument[0]=='-') {
/* '-' means stdin/stdout */
if (argument[1]==0) {
if (!input_filename) input_filename=stdinmark;
@@ -325,6 +326,7 @@ int main(int argc, const char** argv)
/* long commands (--long-word) */
if (argument[1]=='-') {
+ if (!strcmp(argument, "--")) { all_arguments_are_files = 1; continue; }
if (!strcmp(argument, "--compress")) { mode = om_compress; continue; }
if ((!strcmp(argument, "--decompress"))
|| (!strcmp(argument, "--uncompress"))) { mode = om_decompress; continue; }