我正在尝试从 bash 脚本中停用 pythonbrew。在 shell 内键入时pythonbrew off
可以正常工作。
在我的 bash 脚本pythonbrew off
中只是被忽略了。使用回声时,我得到:
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
}