2012-04-04 143 views
0

我試圖從bash腳本中取消激活pythonbrew。 當在shell中輸入pythonbrew off可以正常工作。
在我的bash腳本pythonbrew off只是被忽略。 使用迴音時,我得到:從bash腳本中取消激活pythonbrew

[email protected]:~/Projects/devenv$ echo $("pythonbrew off") 
pythonbrew off: command not found 

調用函數使程序不打印失敗消息退出。
這裏的功能:

function deactivate_pythonbrew() 
{ 
    echo "Detecting whether Pythonbrew is installed." 
    pythonbrew_version="$(pythonbrew --version 2>&1)" 
    if [ -n $pythonbrew_version ] 
    then 
     echo "Pythonbrew $pythonbrew_version found." 

     if [ -n $pythonbrew ] 
     then 
      pythonbrew off || echo "Failed to deactivate pythonbrew. Aborting." && exit $? 
     else 
      echo "Pythonbrew is inactive. Skipping." 
     fi 
    else 
     echo "Pythonbrew is not installed. Skipping." 
    fi 
} 

回答

0

事實證明,我不得不source $HOME/.bashrc/etc/bashrc因爲功能不被導入到腳本。 我在我的〜/ .bashrc文件中有source $HOME/.bashrc/etc/bashrc,但據我所知,函數不會被導入到子進程中。