summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-04-05 17:48:58 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-04-05 17:48:58 -0400
commitebe8873448cdaadbca620bf6eb5e22f9e79f25fc (patch)
tree61cc1a4894316bf41902f1f12fee4cad385d87c0
parentf3b9a35e52b3b1d40e1d4f3a749e8faf32fb3d7f (diff)
downloadcmd2-git-ebe8873448cdaadbca620bf6eb5e22f9e79f25fc.tar.gz
Fixed path completion case where cwd is just a slash
-rw-r--r--cmd2/cmd2.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index a621e459..ddc3945b 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1141,7 +1141,11 @@ class Cmd(cmd.Cmd):
# Remove cwd if it was added to match the text readline expects
if cwd_added:
- matches = [cur_path.replace(cwd + os.path.sep, '', 1) for cur_path in matches]
+ if cwd == os.path.sep:
+ to_replace = cwd
+ else:
+ to_replace = cwd + os.path.sep
+ matches = [cur_path.replace(to_replace, '', 1) for cur_path in matches]
# Restore the tilde string if we expanded one to match the text readline expects
if expanded_tilde_path: