Mig*_*ell 5 shell zsh process-substitution
我想使用 zsh 的进程替换来创建一个临时文件,然后可以由另一个程序读取。但是,它生成的文件没有文件扩展名,因此读取它的程序拒绝继续。
这可以通过以下方式证明:
$ echo =(ls)
/tmp/zshmgIWvT
Run Code Online (Sandbox Code Playgroud)
我想要发生的是它产生一个文件名 /tmp/zshmgIWvT.wav
zsh 可以吗?
thr*_*rig 13
在某个人的深处zshparam(1)可能会发现:
TMPSUFFIX
A filename suffix which the shell will use for temporary files
created by process substitutions (e.g., `=(list)'). Note that
the value should include a leading dot `.' if intended to be
interpreted as a file extension. The default is not to append
any suffix, thus this parameter should be assigned only when
needed and then unset again.
Run Code Online (Sandbox Code Playgroud)
所以
% () { TMPSUFFIX=.wav; print =(ls); unset TMPSUFFIX }
/Users/jhqdoe/tmp/zshsQhnnV.wav
% print $TMPSUFFIX
%
Run Code Online (Sandbox Code Playgroud)
您可能还想TMPPREFIX特别在共享系统上进行设置,以帮助避免各种/tmp安全漏洞。
| 归档时间: |
|
| 查看次数: |
200 次 |
| 最近记录: |