Skip to content

Commit

Permalink
Use ` as escape character in PowerShell (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
bebound committed Jun 11, 2023
1 parent e4a9086 commit 5198138
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion argcomplete/finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,14 @@ def quote_completions(
special_chars = ""
completions = [c.replace("'", r"'\''") for c in completions]

# PowerShell uses ` as escape character.
if os.getenv('PSModulePath'):
escape_char = '`'
special_chars = special_chars.replace('`', '')
else:
escape_char = "\\"
for char in special_chars:
completions = [c.replace(char, "\\" + char) for c in completions]
completions = [c.replace(char, escape_char + char) for c in completions]

if self.append_space:
# Similar functionality in bash was previously turned off by supplying the "-o nospace" option to complete.
Expand Down

0 comments on commit 5198138

Please sign in to comment.