summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-20 01:58:42 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-20 01:58:42 -0400
commit7900be9b58d5e856d74c4498d37775056d548503 (patch)
tree199c565a97a895d0cb72470b87ab25a72b9e2c2f /cmd2.py
parent2a3c79231521409984318c22b28150e232a0b637 (diff)
downloadcmd2-git-7900be9b58d5e856d74c4498d37775056d548503.tar.gz
Not altering copy of completion_token
Diffstat (limited to 'cmd2.py')
-rw-r--r--cmd2.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/cmd2.py b/cmd2.py
index 92a3c043..b30c64c3 100644
--- a/cmd2.py
+++ b/cmd2.py
@@ -460,14 +460,9 @@ def path_complete(text, line, begidx, endidx, dir_exe_only=False, dir_only=False
set_allow_closing_quote(False)
return [os.path.sep]
- elif completion_token.startswith('~'):
-
- # Tilde without separator between path is invalid
- if not completion_token.startswith('~' + os.path.sep):
- return []
-
- # Expand "~" to the real user directory
- completion_token = os.path.expanduser(completion_token)
+ # Tilde without separator between path is invalid
+ elif completion_token.startswith('~') and not completion_token.startswith('~' + os.path.sep):
+ return []
# If the token does not have a directory, then use the cwd
elif not os.path.dirname(completion_token):
@@ -476,6 +471,9 @@ def path_complete(text, line, begidx, endidx, dir_exe_only=False, dir_only=False
# Build the search string
search_str = os.path.join(dirname, completion_token + '*')
+ # Expand "~" to the real user directory
+ search_str = os.path.expanduser(search_str)
+
# Find all matching path completions
path_completions = glob.glob(search_str)