定义引用其他别名的别名 [英] Define alias that references other aliases
问题描述
我需要能够在Debian shell中为我当前正在研究的项目定义一个别名,其中包括其他别名.
I'd need to be able to define an alias in a Debian shell that includes other aliases, for a project I'm currently working on.
让我们看一个代码示例,使事情更清楚.
Let's look at a code example to make things more clear.
-
别名foo = foo
-
别名bar = bar
如果我运行 type foo
,则返回 foo别名为'foo'
,而 type bar
返回 bar别名为'bar'
.到这里一切都很好.现在,我遇到了问题.
If I run type foo
it returns foo is aliased to 'foo'
, and type bar
returns bar is aliased to 'bar'
. Up to here all fine. Now, where I'm having the problem.
-
别名foobar = $ foo $ bar
不起作用. type foobar
返回 foobar的别名为``
.
我已经尝试过 alias foobar = $ {foo} $ {bar}
,它也不起作用.
I've tried alias foobar=${foo}${bar}
and it doesn't work either.
一旦我开始工作,在最终版本中,我实际上需要在两个别名之间添加一些文本,想象一下: alias fooandbar = $ {foo} and $ {bar}
.
Once I get this working, in the final version I actually need some text in between the two aliases, imagine something like: alias fooandbar=${foo}and${bar}
.
任何人都可以帮忙吗?
推荐答案
要在另一个别名中重用别名,请使用:
To reuse alias in another alias use:
foobar='foo;bar'
但是我建议您考虑使用shell函数来更好地控制它.
However I would suggest you to consider using shell function to get better control over this.
这篇关于定义引用其他别名的别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!