From 1962f40f4afd227944ae5b75d8fba9b4965f69f5 Mon Sep 17 00:00:00 2001 From: Klaus Alexander Seistrup Date: Fri, 31 Jul 2015 18:25:28 +0200 Subject: [PATCH] Prevent os.path.normpath() from removing current dir. Take 2. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous fix didn't take other current dirs and other path separators into consideration, and so it fixed the ‘./’ problem on Linux/Unix but not e.g. ‘.\’ on Windows. In an attempt to be platform agnostic this patch uses os.curdir and os.sep. Fixes upstream #307. --- xonsh/completer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xonsh/completer.py b/xonsh/completer.py index 960ae055d..e32cd8b04 100644 --- a/xonsh/completer.py +++ b/xonsh/completer.py @@ -37,8 +37,9 @@ for ((i=0;i<${{#COMPREPLY[*]}};i++)) do echo ${{COMPREPLY[i]}}; done def _normpath(p): # Prevent normpath() from removing initial ‘./’ - if p.startswith('./'): - return './' + os.path.normpath(p[2:]) + here = os.curdir + os.sep + if p.startswith(here): + return os.path.join(os.curdir, os.path.normpath(p[len(here):])) return os.path.normpath(p)