小编iXô*_*iXô的帖子

在 bash 中,声明一个依赖于当前变量内容的别名

我想声明一个别名(在 my 中.bash_profile),它将在使用别名时使用变量的内容(值),而不是在定义时使用。例如,

alias goSomeWhere="cd $BASE/somewhere"
Run Code Online (Sandbox Code Playgroud)

$BASE定义别名时未设置,仅在使用时设置。但是,因为$BASE是在定义别名时(在登录时)计算的,所以goSomeWhere别名被解释为cd /somewhere.

如何延迟对变量的评估,直到执行别名?

linux bash shell environment-variables

5
推荐指数
1
解决办法
1621
查看次数

标签 统计

bash ×1

environment-variables ×1

linux ×1

shell ×1