Using this lz4 command:
$ apt search ^lz4$
Sorting... Done
Full Text Search... Done
lz4/focal,now 1.9.2-2 amd64 [installed,automatic]
Fast LZ compression algorithm library - tool
$ lz4 --version
*** LZ4 command line interface 64-bits v1.9.2, by Yann Collet ***
This command normally creates a filename.lz4
file (just like gzip does):
$ lz4 -9 -k filename
However, this command does not, and instead writes to stdout when I'm not telling it to:
$ t=$(lz4 -9 -k filename)
Warning : using stdout as default output. Do not rely on this behavior: use explicit `-c` instead !
bash: warning: command substitution: ignored null byte in input
Why is it doing this? Is it a bug, or is there a reason documented somewhere?
The behaviour appears to be a feature - not a bug. I can't find it documented anywhere except in the source code:
On Linux,
IS_CONSOLE
usesisatty
to determine whether file desscriptors are connected to a terminal.As suggested in the comment, you can use the
-m
option to force generation of an output file in cases where there is no tty: