为什么非交互的Bash shell的别名不工作 [英] Why aliases in a non-interactive Bash shell do not work
问题描述
我想在一个非交互式bash shell中使用别名。我已经定义我的别名,在〜/ .bashrc中
我已经设置变量 BASH_ENV =〜/ startUpFile
。该startUpFile的内容源的〜/ .bashrc
。
I am trying to use aliases in a non-interactive bash shell. I have defined my aliases in ~/.bashrc
and I have set the variable BASH_ENV=~/startUpFile
. The contents of the startUpFile are source ~/.bashrc
.
我可以看到我的别名被识别,当我执行别名
命令。但是,如果我尝试使用〜/ .bashrc中
定义的别名,Bash可以不承认它。它给我未知命令错误。
I can see that my aliases are recognized, when I execute the alias
command. However, if I try to use an alias defined in ~/.bashrc
, Bash can't recognized it. It gives me the unknown command error.
通过tcsh外壳是pretty容易做到这一点,因为〜/ .cshrc中
文件始终读取。
With the TCSH shell it is pretty easy to do this because the ~/.cshrc
file is always read.
任何想法如何,我可以用Bash shell中做到这一点?
Any ideas how I can do this with a Bash shell?
推荐答案
命令禁用了javascript -s expand_aliases
将允许非交互shell别名扩展。
The command shopt -s expand_aliases
will allow alias expansion in non-interactive shells.
这篇关于为什么非交互的Bash shell的别名不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!