Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Unexpected behavior for completion funcion _remote_files()
- X-seq: zsh-workers 39193
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Yoshio Hanawa <y@xxxxxx>
- Subject: Re: Unexpected behavior for completion funcion _remote_files()
- Date: Tue, 06 Sep 2016 17:55:59 +0200
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1473177359; bh=pYZ6LnobQfd7sqXaorWqzgKOrwpQwFUsKNqZ9ls/V2o=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=opge2SE0qklnzsVLH8Tu7LedDN+SdmVZ5/WxPq2r7wtaMkGDvTFtoDrniLYx/hbN3fQAtk+bNM1uuKOPdh9sBWwFpf/NyCac31ARVzdULmMzZT5jLP+/zklRUz20AhP/NQ/33mTjCMnMMKqF/YcO6nOTCIzdhJikePjcOhVmxACXGaC2KuD0IzkCuCIKh3xb2zmoeU9DMcEYrR0hs+l76ht6qG1e/AzetcmeeY5l9ltQU5s+KS0bQ+v8AuRIb/3KQpl2F3DE1bgoBBUAjCTiaEU+2UDdA/HMYSl1hNtLNWY1bkE202S2nM5oLs9BmcYE0PqVBxbgZL71SBpVG5McnA==
- In-reply-to: <CA+JhjB_Ry--Va9-Vz4z_6V7iEeEpJ2UbdAsFJFPe7vYcknB60A@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CA+JhjB_Ry--Va9-Vz4z_6V7iEeEpJ2UbdAsFJFPe7vYcknB60A@mail.gmail.com>
Yoshio Hanawa wrote:
> When I tried Zsh completion funcion _remote_files with 'docker exec ...', I
> found the command line options for _remote_files (in this case, 'exec ...')
> are passed directly to compadd. I think it's unexpected behavior.
Yes, _remote_files shouldn't pass options that come after -- to compadd.
Thanks for the report.
> "$@" in compadd arguments seems to be unnecessary, so should simply be
> removed.
Ideally, any extra options from before -- should be passed on.
At the very least it should allow for them being there - currently, just using
_wanted with _remote_files fails. Using this would allow docker
completion to override the description given with the files if 'remote
file' is not applicable.
> The following patch works fine on my environment.
Could you perhaps try the following? I don't have docker so have only
tested this with ssh.
Thanks
Oliver
diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files
index db33164..54bd438 100644
--- a/Completion/Unix/Type/_remote_files
+++ b/Completion/Unix/Type/_remote_files
@@ -28,16 +28,19 @@
# There should be coloring based on all the different ls -F classifiers.
-local expl rempat remfiles remdispf remdispd args cmd cmd_args suf ret=1
+local expl rempat remfiles remdispf remdispd args cmd suf ret=1
+local -a args cmd_args
local glob host
if zstyle -T ":completion:${curcontext}:files" remote-access; then
# Parse options to _remote_files. Stops at the first "--".
zparseopts -D -E -a args / g:=glob h:=host
- shift
(( $#host)) && shift host || host="${IPREFIX%:}"
+ args=( ${argv[1,(I)--]} )
+ shift ${#args}
+ args[-1]=()
# Command to run on the remote system.
cmd="$1"
shift
@@ -45,9 +48,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
# Handle arguments to ssh.
if [[ $cmd == ssh ]]; then
zparseopts -D -E -a cmd_args p: 1 2 4 6 F:
- cmd_args="-o BatchMode=yes $cmd_args -a -x"
+ cmd_args=( -o BatchMode=yes "$cmd_args[@]" -a -x )
else
- cmd_args="$@"
+ cmd_args=( "$@" )
fi
if [[ -z $QIPREFIX ]]
@@ -74,8 +77,8 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
while _tags; do
while _next_label files expl ${suf:-remote directory}; do
[[ -n $suf ]] &&
- compadd "$@" "$expl[@]" -d remdispf ${(q)remdispf%[*=|]} && ret=0
- compadd ${suf:+-S/} -r "/ \t\n\-" "$@" "$expl[@]" -d remdispd \
+ compadd "$args[@]" "$expl[@]" -d remdispf ${(q)remdispf%[*=|]} && ret=0
+ compadd ${suf:+-S/} -r "/ \t\n\-" "$args[@]" "$expl[@]" -d remdispd \
${(q)remdispd%/} && ret=0
done
(( ret )) || return 0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author