【发布时间】:2015-09-10 11:19:34
【问题描述】:
我需要能够在包含其他别名的 Debian shell 中为我目前正在进行的项目定义一个别名。
让我们看一个代码示例,让事情更清楚。
alias foo=fooalias bar=bar
如果我运行type foo,它将返回foo is aliased to 'foo',而type bar 返回bar is aliased to 'bar'。到这里一切都好。现在,我遇到了问题。
alias foobar=$foo$bar
不起作用。 type foobar 返回foobar is aliased to ''。
我试过alias foobar=${foo}${bar},也不管用。
一旦我得到这个工作,在最终版本中,我实际上需要在两个别名之间添加一些文本,想象一下:alias fooandbar=${foo}and${bar}。
有人可以帮忙吗?
【问题讨论】:
-
您混淆了别名和变量。它们是两种不同的东西。您不能使用 $xx 语法来引用别名。