我想通过使用
第二个调用从未完成,输出结果为
注意:
更新
为了调试,我将
system
命令,从Perl中运行已在我的~/.bashrc
中别名化的命令。它可以成功地运行一次,但当我运行两次时,第二个调用将作为后台作业运行,然后被暂停(与按<CTRL-Z>
相同),我必须键入fg
来完成命令。例如:use strict;
use warnings;
system ('bash -ic "my_cmd"');
system ('bash -ic "my_cmd"');
第二个调用从未完成,输出结果为
[1]+ Stopped a.pl
。注意:
- 替换
my_cmd
为其他命令(例如ls
),将得到相同的结果。 - 似乎与我的
~/.bashrc
文件的内容无关。我尝试将其全部删除,问题仍然存在。
更新
为了调试,我将
~/.bashrc
文件简化为:echo "Entering ~/.bashrc .."
alias my_cmd="ls"
alias
将我的~/.bash_profile
文件更改为
if [ -f ~/.bashrc ]; then
echo "Entering ~/.bash_profile .."
. ~/.bashrc
fi
当前正在运行:
system ('bash -lc "my_cmd"');
system ('bash -lc "my_cmd"');
提供
Entering ~/.bash_profile ..
Entering ~/.bashrc ..
alias my_cmd='ls'
bash: my_cmd: command not found
Entering ~/.bash_profile ..
Entering ~/.bashrc ..
alias my_cmd='ls'
bash: my_cmd: command not found
并且运行
system ('bash -ic "my_cmd"');
system ('bash -ic "my_cmd"');
提供
Entering ~/.bashrc ..
alias my_cmd='ls'
a.pl p.sh
[1]+ Stopped a.pl