zsh - 过程替换 =(list) 在参数中间

标签 zsh

如何使用=(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/

相关文章:

ubuntu - 终端在 `npm start` 之后不显示输出

zsh - 如何从 Zsh 中的 $PATH 中删除路径并将其添加到开头而不重复?

bash - 在 bash 中将十六进制转换为十进制

terminal - 如何在命令行中创建一个永久的 zsh 别名?

linux - source、zsh、 "."和直接shell脚本调用的区别

colors - cucumber :管道输出不掉色

zsh - 如何使 zsh 中的右箭头键表现得像鱼的向前单字符

shell - zsh 键绑定(bind) : cannot bind to an empty key sequence

shell - zsh 中的 export USERNAME=root 给出权限错误

bash - 获取脚本目录的 bash 脚本的 zsh 等价物是什么?