1
0
mirror of https://github.com/facebook/zstd.git synced 2025-08-01 09:47:01 +03:00
only disable `--rm` at end of command line parsing,
so that `-c` only disables `--rm` if it's effectively selected,
and not if it's overriden by a later `-o FILE` command.
This commit is contained in:
Yann Collet
2024-03-11 11:38:55 -07:00
parent 372fddf4e6
commit c610a01d7d
2 changed files with 17 additions and 7 deletions

View File

@ -1176,7 +1176,10 @@ int main(int argCount, const char* argv[])
operation=zom_decompress; argument++; break;
/* Force stdout, even if stdout==console */
case 'c': forceStdout=1; outFileName=stdoutmark; removeSrcFile=0; argument++; break;
case 'c': forceStdout=1; outFileName=stdoutmark; argument++; break;
/* destination file name */
case 'o': argument++; NEXT_FIELD(outFileName); break;
/* do not store filename - gzip compatibility - nothing to do */
case 'n': argument++; break;
@ -1202,9 +1205,6 @@ int main(int argCount, const char* argv[])
/* test compressed file */
case 't': operation=zom_test; argument++; break;
/* destination file name */
case 'o': argument++; NEXT_FIELD(outFileName); break;
/* limit memory */
case 'M':
argument++;
@ -1367,6 +1367,14 @@ int main(int argCount, const char* argv[])
#endif
}
/* disable --rm when writing to stdout */
if (!strcmp(outFileName, stdoutmark)) {
if (removeSrcFile) {
DISPLAYLEVEL(2, "warning: source not removed when writing to stdout \n");
removeSrcFile = 0;
}
}
/* Check if benchmark is selected */
if (operation==zom_bench) {
#ifndef ZSTD_NOBENCH