Skip to content

Commit f437f69

Browse files
committed
Intermediate changes
commit_hash:65c39fc8ac4420b89c1118208082273710155e1a
1 parent 7039e86 commit f437f69

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

contrib/python/argcomplete/py3/.dist-info/METADATA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.4
22
Name: argcomplete
3-
Version: 3.6.0
3+
Version: 3.6.1
44
Summary: Bash tab completion for argparse
55
Project-URL: Homepage, https://github.com/kislyuk/argcomplete
66
Project-URL: Documentation, https://kislyuk.github.io/argcomplete

contrib/python/argcomplete/py3/argcomplete/finders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def quote_completions(
515515
# Bash mangles completions which contain characters in COMP_WORDBREAKS.
516516
# This workaround has the same effect as __ltrim_colon_completions in bash_completion
517517
# (extended to characters other than the colon).
518-
if last_wordbreak_pos:
518+
if last_wordbreak_pos is not None:
519519
completions = [c[last_wordbreak_pos + 1 :] for c in completions]
520520
special_chars += "();<>|&!`$* \t\n\"'"
521521
elif cword_prequote == '"':

contrib/python/argcomplete/py3/argcomplete/packages/_shlex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ def read_token(self):
177177
elif self.whitespace_split:
178178
self.token = nextchar
179179
self.state = 'a'
180+
# Modified by argcomplete: Record last wordbreak position
181+
if nextchar in self.wordbreaks:
182+
self.last_wordbreak_pos = len(self.token) - 1
180183
else:
181184
self.token = nextchar
182185
if self.token or (self.posix and quoted):

contrib/python/argcomplete/py3/argcomplete/scripts/activate_global_python_argcomplete.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,33 @@ def append_to_config_file(path, shellcode):
121121
fh.write(shellcode)
122122
print("Added.", file=sys.stderr)
123123

124-
125-
def link_user_rcfiles():
126-
# TODO: warn if running as superuser
124+
def link_zsh_user_rcfile(zsh_fpath=None):
127125
zsh_rcfile = os.path.join(os.path.expanduser(os.environ.get("ZDOTDIR", "~")), ".zshenv")
128-
append_to_config_file(zsh_rcfile, zsh_shellcode.format(zsh_fpath=get_activator_dir()))
126+
append_to_config_file(zsh_rcfile, zsh_shellcode.format(zsh_fpath=zsh_fpath or get_activator_dir()))
129127

128+
def link_bash_user_rcfile():
130129
bash_completion_user_file = os.path.expanduser("~/.bash_completion")
131130
append_to_config_file(bash_completion_user_file, bash_shellcode.format(activator=get_activator_path()))
132131

133132

133+
def link_user_rcfiles():
134+
# TODO: warn if running as superuser
135+
link_zsh_user_rcfile()
136+
link_bash_user_rcfile()
137+
138+
def add_zsh_system_dir_to_fpath_for_user():
139+
if "zsh" not in os.environ.get("SHELL", ""):
140+
return
141+
try:
142+
zsh_system_dir = get_zsh_system_dir()
143+
fpath_output = subprocess.check_output([os.environ["SHELL"], "-c", 'printf "%s\n" "${fpath[@]}"'])
144+
for fpath in fpath_output.decode().splitlines():
145+
if fpath == zsh_system_dir:
146+
return
147+
link_zsh_user_rcfile(zsh_fpath=zsh_system_dir)
148+
except (FileNotFoundError, subprocess.CalledProcessError):
149+
pass
150+
134151
def main():
135152
global args
136153
args = parser.parse_args()
@@ -160,6 +177,8 @@ def main():
160177
for destination in destinations:
161178
install_to_destination(destination)
162179

180+
add_zsh_system_dir_to_fpath_for_user()
181+
163182
if args.dest is None:
164183
print("Please restart your shell or source the installed file to activate it.", file=sys.stderr)
165184

contrib/python/argcomplete/py3/argcomplete/shell_integration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def shellcode(executables, use_defaults=True, shell="bash", complete_arguments=N
166166
executables_list = " ".join(quoted_executables)
167167
script = argcomplete_script
168168
if script:
169-
function_suffix = "_" + script
169+
# If the script path contain a space, this would generate an invalid function name.
170+
function_suffix = "_" + script.replace(" ", "_SPACE_")
170171
else:
171172
script = ""
172173
function_suffix = ""

contrib/python/argcomplete/py3/ya.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
PY3_LIBRARY()
44

5-
VERSION(3.6.0)
5+
VERSION(3.6.1)
66

77
LICENSE(Apache-2.0)
88

0 commit comments

Comments
 (0)