]> git.ipfire.org Git - thirdparty/zstd.git/commit
refactor : --rm is ignored with stdout
authorYann Collet <cyan@fb.com>
Sat, 21 Jan 2023 01:53:05 +0000 (17:53 -0800)
committerYann Collet <cyan@fb.com>
Sat, 21 Jan 2023 02:04:55 +0000 (18:04 -0800)
commitcee6bec9fa6aa249f2df9f84165b682eb793eab4
treec19d7f30edb33133705002b3804f125a3974f7ae
parentd9280afb7dfb39aa6417e7465c3905f2de864bbd
refactor : --rm is ignored with stdout

`zstd` CLI has progressively moved to the policy of
ignoring `--rm` command when the output is `stdout`.
The primary drive is to feature a behavior more consistent with `gzip`,
when `--rm` is the default, but is also ignored when output is `stdout`.
Other policies are certainly possible, but would break from this `gzip` convention.

The new policy was inconsistenly enforced, depending on the exact list of commands.
For example, it was possible to circumvent it by using `-c --rm` in this order,
which would re-establish source removal.

- Update the CLI so that it necessarily catch these situations and ensure that `--rm` is always disabled when output is `stdout`.
- Added a warning message in this case (for verbosity 3 `-v`).
- Added an `assert()`, which controls that `--rm` is no longer active with `stdout`
- Added tests, which control the behavior, even when `--rm` is added after `-c`
- Removed some legacy code which where trying to apply a specific policy for the `stdout` + `--rm` case, which is no longer possible
programs/fileio.c
programs/fileio.h
programs/zstdcli.c
tests/playTests.sh