New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input file is removed without being compressed with redirecting STDOUT together with --rm #1193
Comments
Hi @nobodyinperson, # lz4
cd
mkdir lz4-issue-1193
cd lz4-issue-1193/
touch inputfile
lz4 -1 -c inputfile > /dev/null
ls
# inputfile # gzip
cd
mkdir lz4-issue-1193-gz
cd lz4-issue-1193-gz/
touch inputfile
gzip -1 -c inputfile > /dev/null
ls
# inputfile # xz
cd
mkdir lz4-issue-1193-xz
cd lz4-issue-1193-xz/
touch inputfile
xz -z -0 -c inputfile > /dev/null
ls
# inputfile |
Sure I can and now that I know my data is being removed otherwise I definitely will 😉 Still, I think preventing data loss should be top priority so an accidental misuse of options and redirection should absolutely not delete data. In the above case, a user that just doesn't want to see the output of their |
gzip, zstd and xz all behave as expected (still saving the compressed output file before deleting the source file when redirecting STDOUT), lz4 behaves differently here: ❯ touch bla
❯ gzip bla > /dev/null
❯ ls
bla.gz
❯ rm bla.gz
❯ touch bla
❯ zstd bla --rm > /dev/null
bla : ( 0 B => 13 B, bla.zst)
❯ ls
bla.zst
❯ rm bla.zst
❯ touch bla
❯ xz bla >/dev/null
❯ ls
bla.xz
❯ touch bla
❯ lz4 bla --rm > /dev/null
Warning : using stdout as default output. Do not rely on this behavior: use explicit `-c` instead !
❯ ls
❯ # lz4 removes input file without writing compressed output file when redirecting STDOUT, gzip, xz and zstd don't |
Commenting this block results in the intuitive behaviour (not writing compressed data to STDOUT even if STDOUT is not a TTY): Lines 680 to 688 in 8a31e64
According to the warning this apparently seems to be an unstable default. If it's undecided anyway, how about making it behave the same way as other compression clis? |
Looking back at this issue, Historically, To address these last incompatibilities, and make
On a longer term perspective, we can still consider evolutions to Another one is to ditch the "implicit
Since this warning has been set in 2019, almost 5 years ago, we could consider that enough time has passed to warn most |
Since it seems this should be triaged, I set a milestone |
Describe the bug
Input file is removed without being compressed when
--rm
is given and stdout is redirected.Expected behavior
Input file stays untouched and is not removed.
To Reproduce
Steps to reproduce the behavior:
lz4 --rm inputfile >/dev/null
Warning : using stdout as default output. Do not rely on this behavior: use explicit '-c' instead !
inputfile
was deleted (check withls
)System (please complete the following information):
Additional context
Add any other context about the problem here.
Noted this while developing a compression algorithm benchmarker: https://gitlab.com/nobodyinperson/compression-algorithm-benchmark
https://fosstodon.org/@nobodyinperson/109404289543643442
The text was updated successfully, but these errors were encountered: