[英]Bash expansion error defining function with pandoc
I'm using the advice here to setup an alias to convert markdown to man
style output using the command, 我在这里使用建议来设置别名,以使用命令将markdown转换为
man
样式输出,
alias mdless="pandoc -s -f markdown -t man \!* | groff -T utf8 -man | less"
I keep getting the error: pandoc: !*: openFile: does not exist (No such file or directory)
我不断收到错误消息:
pandoc: !*: openFile: does not exist (No such file or directory)
But the command words fine if I just do pandoc -s -f markdown -t man README.md | groff -T utf8 -man | less
但是,如果我只是执行
pandoc -s -f markdown -t man README.md | groff -T utf8 -man | less
则命令字就可以了pandoc -s -f markdown -t man README.md | groff -T utf8 -man | less
pandoc -s -f markdown -t man README.md | groff -T utf8 -man | less
Is there something wrong with this bash expansion syntax? 这个bash扩展语法有什么问题吗?
That example is a tcsh
alias not a bash
alias. 该示例是
tcsh
别名,而不是bash
别名。 That's why you needed to add the =
that the original had to yours to get it to work at all. 这就是为什么您需要在原始文件中添加
=
,以使其完全起作用。
The problem is that tcsh
(apparently) removes escaping backslashes from history expansion exclamation points that it sees in double quoted strings: 问题是,
tcsh
(显然)从在双引号字符串中看到的历史记录扩展感叹号中删除了转义的反斜杠:
tcsh$ echo "\!*"
!*
Whereas bash
(for some reason I've never understood) does not do that: 而
bash
(出于某些我从未理解的原因)不这样做:
bash$ echo "\!*"
\!*
I'm not sure you can get an exact duplicate of that alias in bash
since I don't think bash will do history expansion on an alias expansion so the closest you can get is a function that takes files as arguments: 我不确定您能否在
bash
获得该别名的完全相同的副本,因为我认为bash不会在别名扩展上进行历史扩展,因此您能获得的最接近的函数是一个以文件为参数的函数:
mdless() {
pandoc -s -f markdown -t man "$@" | groff -T utf8 -man | less
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.