about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorAbdo Roig-Maranges <abdo.roig@gmail.com>2014-05-03 15:30:21 +0200
committerAbdo Roig-Maranges <abdo.roig@gmail.com>2014-05-03 15:43:24 +0200
commita5bf7552f85826535ad25b8b18346a5fd998e8f4 (patch)
tree3273c06e38f6ea34ac92e901e9e42ee3cdb46a90 /ranger
parent8bf5af78620e9c4ee1959aeb81b01273d1ca5aba (diff)
downloadranger-a5bf7552f85826535ad25b8b18346a5fd998e8f4.tar.gz
Fix cdpath commit, which was broken in several ways
This fixes commit 04681ff7ceb8a as follows:

 - check when cdpath is None. Otherwise split fails on None objects and
   causes ranger to crashes when CDPATH is not set in the environment.

 - actually set cdpath variable in the lowercase case. Before it was not
   assigned to any variable.

 - join paths with os.path.join instead of concatenating with '/'.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/actions.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 8424b51d..ea4b54eb 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -451,16 +451,12 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
     def enter_dir(self, path, remember=False, history=True):
         """Enter the directory at the given path"""
         cwd = self.thisdir
-        # bash and ksh syntax
-        cdpath = os.environ.get('CDPATH', None)
-        if cdpath == "":
-            # zsh and csh syntax
-            os.environ.get('cdpath', None)
-        paths = cdpath.split(':')
+        # csh variable is lowercase
+        cdpath = os.environ.get('CDPATH', None) or os.environ.get('cdpath', None)
         result = self.thistab.enter_dir(path, history=history)
-        if result == 0:
-            for p in paths:
-                curpath = p + '/' + path
+        if result == 0 and cdpath:
+            for p in cdpath.split(':'):
+                curpath = os.path.join(p, path)
                 if os.path.isdir(curpath):
                     result = self.thistab.enter_dir(curpath, history=history)
                     break