From 3a7f211fb60803574424f1558b6ef19ede68e3ef Mon Sep 17 00:00:00 2001 From: William Ting Date: Mon, 4 Jun 2012 08:06:25 -1000 Subject: [PATCH] Obey AUTOJUMP_KEEP_SYMLINKS when testing current directory against paths. This is to make sure we don't jump into our current directory when the symlinks option is enabled. --- bin/autojump | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/autojump b/bin/autojump index 9ab52de..f1acb1d 100755 --- a/bin/autojump +++ b/bin/autojump @@ -54,6 +54,10 @@ ALWAYS_IGNORE_CASE = False if 'AUTOJUMP_IGNORE_CASE' in os.environ and os.environ.get('AUTOJUMP_IGNORE_CASE') == '1': ALWAYS_IGNORE_CASE = True +KEEP_SYMLINKS = False +if 'AUTOJUMP_KEEP_SYMLINKS' in os.environ and os.environ.get('AUTOJUMP_KEEP_SYMLINKS') == '1': + KEEP_SYMLINKS = True + if CONFIG_DIR == os.path.expanduser('~'): DB_FILE = CONFIG_DIR + '/.autojump.txt' else: @@ -74,7 +78,7 @@ class Database: def add(self, path, increment = 10): """ - Increment existing paths or initialize new ones to 0. + Increment existing paths or initialize new ones to 10. """ if path not in self.data: self.data[path] = increment @@ -359,7 +363,10 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False): Find max_matches paths that match the pattern, and add them to the result_list. """ try: - current_dir = decode(os.path.realpath(os.curdir)) + if KEEP_SYMLINKS: + current_dir = decode(os.curdir) + else: + current_dir = decode(os.path.realpath(os.curdir)) except OSError: current_dir = None