使用这个lz4命令:
$ 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 ***这个命令通常创建一个filename.lz4文件(就像gzip一样):
$ lz4 -9 -k filename但是,这个命令没有,而是在我没有告诉它时写到stdout:
$ 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它为什么要这么做?它是一个bug,还是有什么原因被记录在某个地方?
发布于 2021-03-10 13:31:48
这种行为似乎是一个特征,而不是一个bug。除了在源代码中,我在任何地方都找不到文档:
/* No output filename ==> try to select one automatically (when possible) */
while ((!output_filename) && (multiple_inputs==0)) {
if (!IS_CONSOLE(stdout)) {
/* Default to stdout whenever stdout is not the console.
* Note : this policy may change in the future, therefore don't rely on it !
* To ensure `stdout` is explicitly selected, use `-c` command flag.
* Conversely, to ensure output will not become `stdout`, use `-m` command flag */
DISPLAYLEVEL(1, "Warning : using stdout as default output. Do not rely on this behavior: use explicit `-c` instead ! \n");
output_filename=stdoutmark;
break;
.
.
}在Linux上,IS_CONSOLE使用isatty来确定文件desscriptors是否连接到终端。
正如注释中所建议的,在没有tty的情况下,可以使用-m选项强制生成输出文件:
t=$(lz4 -9 -k -m filename)https://askubuntu.com/questions/1322528
复制相似问题