如何使用=(list)
- 在争论中间进行风格的过程替换?
这有效:
% echo =(echo)
/tmp/zshxxxxxx
这也是:
% echo =(echo):works
/tmp/zshxxxxxx:works
但这并不:
% echo broken:=(echo)
zsh: missing end of string
值得注意的是,这也有效:
% echo works:<(echo)
works:/proc/self/fd/11
问题是=(list)
只能站在争论的开始。引用ZSH手册:
The expression may be preceded or followed by other strings except that, to prevent clashes with commonly occurring strings and patterns, the last form [this is =(list)] must occur at the start of a command argument, and the forms are only expanded when first parsing command or assignment arguments.
我有一个接受 format:filename
形式的参数的工具,并且我需要使用真实文件,而不是管道,所以我不能使用 <(list)
。什么是相当简单且可读的解决方案?
最佳答案
使用参数扩展来“缓冲”进程替换。
% echo fixed:${:-=(echo)}
fixed:/tmp/zshxxxxxx
关于zsh - 过程替换 =(list) 在参数中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50631422/