使用此 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 ***
Run Code Online (Sandbox Code Playgroud)
此命令通常会创建一个filename.lz4文件(就像 gzip 一样):
$ lz4 -9 -k filename
Run Code Online (Sandbox Code Playgroud)
然而,这个命令不会,而是在我没有告诉它时写入标准输出:
$ 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
Run Code Online (Sandbox Code Playgroud)
它为什么要这样做?这是一个错误,还是在某处记录了原因?
该行为似乎是一个功能,而不是一个错误。除了源代码之外,我在任何地方都找不到它的记录:
/* 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;
.
.
}
Run Code Online (Sandbox Code Playgroud)
在 Linux 上,IS_CONSOLE用于isatty确定文件描述符是否连接到终端。
正如评论中所建议的,您可以使用该-m选项在没有 tty 的情况下强制生成输出文件:
t=$(lz4 -9 -k -m filename)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
725 次 |
| 最近记录: |