如何設定運行時計算 $() 的 bash 別名?

如何設定運行時計算 $() 的 bash 別名?

我設定了一個別名:

alias gpgagentexport="eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO"

然而,當我採購我的產品時,就會.bashrc對其$(cat ...)進行評估。但我想在運行別名時評估它gpgagentexport(在內容~/.gpg-agent-info更改後)。

那麼是否有某種轉義、引用或語法來實現這一點?

答案1

使用單引號:

alias gpgagentexport='eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO'

答案2

轉義$也應該有效:

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

相關內容