如何设置在运行时评估 $() 的 bash 别名?

Ham*_*ner 7 bash alias

我设置了一个别名:

alias gpgagentexport="eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO"
Run Code Online (Sandbox Code Playgroud)

然而,当我我的源.bashrc$(cat ...)在该点进行评估。但是我想在运行别名时gpgagentexport(在内容~/.gpg-agent-info更改后)对其进行评估。

那么是否有某种转义、引用或语法来实现这一点?

ang*_*gus 7

使用单引号:

alias gpgagentexport='eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO'
Run Code Online (Sandbox Code Playgroud)


Ber*_*ard 6

转义$应该也有效:

 alias gpgagentexport="eval \$(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO"
Run Code Online (Sandbox Code Playgroud)