Commits

Vincent Hillenbrink  committed 60985a9

Minor bug fix

  • Participants
  • Parent commits fadef2e

Comments (0)

Files changed (2)

File scripts/djenv.mercurial

 # 
 
 hgbaseport=7100
-hgpidfile=$PROJECT_ROOT/tmp/hgserve.pid
 
 # Start hg server in daemon mode and open first argument in browser
 function hgserve() {
     [ -z "$PROJECT_ROOT" ] && echo "No \$PROJECT_ROOT" 1>&2 && return 1
 
+    hgpidfile=$PROJECT_ROOT/tmp/hgserve.pid
+
     # Determine port number
     local numhash=`echo $PROJECT_ROOT | md5 | sed 's/[^0-9]//g'`
     hgport=`expr $hgbaseport + ${numhash:0:2}`
 
 # Shut down hg server
 function hgkill() {
-    kill -9 `cat $hgpidfile 2>&1` > /dev/null 2>&1
+    kill -9 `cat "$hgpidfile" 2>&1` > /dev/null 2>&1
     if [ ! $? -eq 0 ]; then
         echo Server not running or other error 2>&1
     fi

File scripts/djenvlib

         fi
     fi
 
-    # Check settings
+    # Check non-critical settings
     local dirs dir
     for dirs in TEMPLATE_DIRS FIXTURE_DIRS; do
         eval `import_django_settings $dirs`
         return 1
     fi
 
+    # Exit current environment (if any)
     djexit
 
+    # Initialize
     _djenv_init $*
-    [ $? -eq 1 ] && djexit && return 1
 
+    # On error, use djexit for cleanup
+    [ ! $? -eq 0 ] && djexit && return 1
+
+    # Change working directory
     cdroot
 
     return 0
 # Clean up the environment
 function _djenv_cleanup () {
     unset DJANGO_PROJECT DJANGO_SETTINGS \
-        _OLD_DJENV_PS1 _OLD_DJANGO_SETTINGS_MODULE _OLD_PYTHONPATH \
+        _OLD_DJANGO_SETTINGS_MODULE _OLD_PYTHONPATH \
         DJANGO_TEMPLATE_DIRS DJANGO_FIXTURE_DIRS
 }