Prevent os.path.normpath() from removing current dir. Take 2.

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.
This commit is contained in:
Klaus Alexander Seistrup 2015-07-31 18:25:28 +02:00
parent b49d6c958d
commit 1962f40f4a

View file

@ -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)