从bash脚本中取消激活pythonbrew

时间:2012-04-04 22:13:02

标签: linux bash pythonbrew

我正在尝试从bash脚本中停用pythonbrew。 在shell中键入pythonbrew off正常工作 在我的bash脚本中pythonbrew off被忽略了。 当使用echo我得到:

omer@omer-VirtualBox:~/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
}

1 个答案:

答案 0 :(得分:0)

事实证明我必须source $HOME/.bashrc/etc/bashrc因为函数没有导入到脚本中。 我的〜/ .bashrc文件中有source $HOME/.bashrc/etc/bashrc但据我所知,这些函数没有导入子进程。