2012-04-04 7 views
0

Ich versuche Pythonbrew von einem Bash-Skript zu deaktivieren. In der Shell funktioniert die Eingabe pythonbrew off korrekt.
In meinem Bash-Skript pythonbrew off wird einfach ignoriert. wenn echo ich:Deaktivieren von Pythonbrew aus einem Bash-Skript

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

Funktion aufrufen, wird das Programm, ohne das Drucken der Fehlermeldung zu beenden.
Hier ist die Funktion:

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 
} 

Antwort

0

Es stellt sich heraus, dass ich source $HOME/.bashrc/etc/bashrc hatte da Funktionen, um das Skript nicht importiert werden. Ich habe source $HOME/.bashrc/etc/bashrc in meiner ~ /. Bashrc-Datei, aber soweit ich verstehe, werden die Funktionen nicht in einen Unterprozess importiert.

Verwandte Themen