zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Hahler <genml+zsh-workers@thequod.de>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: SSH hostname completion with common suffix and globcomplete inserts characters
Date: Thu, 18 Aug 2016 00:52:47 +0200	[thread overview]
Message-ID: <174db3fa-2af2-d43b-3978-5cb789af4ed9@thequod.de> (raw)
In-Reply-To: <ff26da9c-c16f-d148-1753-a4f55c8cb99f@thequod.de>


[-- Attachment #1.1: Type: text/plain, Size: 2511 bytes --]

> % ssh -F ssh_config2 -test-|.foo.bar
> 
> and a second invocation of the completion will then use the "-t" at the
> beginning (for "escape character (or `none')").
> 
> Should this get quoted on expansion to prevent this?

This would need to be escaped using a backslash at the beginning:

  ssh -F ssh_config2 \-test-.foo.bar

> When quoting it manually, I see a similar issue as described before (see
> below), where
> 
>   ssh -F ssh_config2 '-test-<TAB>.foo.bar'
> 
> gets expanded to
> 
>   ssh -F ssh_config2 '-test-BR.foo.bar'
> 
> (without the globcomplete option though!)

The insertion of "BR" does not happen with "zsh -f" though.  It is
caused by matcher-list zstyle setting in my config: 'r:|[._-]=*'

My full setting (based on the one from oh-my-zsh):

  zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' \
    'm:{[:upper:]}={[:lower:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'

While looking at it, it seems like 'r:|[._-]=* r:|=*' is redundant, but
the "COMPLETION MATCHING CONTROL" section in zshcompwid(1) is not really
trivial.

For some other reason I cannot reproduce the issue of "BR" being
inserted when using ssh_config2 with "zsh -f" just by using the same
matcher-list zstyle config.


> On 17.08.2016 21:16, Daniel Hahler wrote:
>> When using TAB completion (via expand-or-complete, and "setopt
>> globcomplete") on a partial hostname where alternatives with a common
>> suffix exist, the second invocation of TAB will insert some character(s)
>> that make it fail to complete afterwards.
>>
>>
>> % autoload -Uz compinit
>> % compinit
>> % echo "Host test-05827d88.foo.bar test-6cae9ce0.foo.bar" > ssh_config
>> % setopt globcomplete
>>
>> With
>>
>> % ssh -F ssh_config test-<TAB>
>>
>> You will get:
>>
>> % ssh -F ssh_config test-|.foo.bar
>>
>> Pressing TAB again results in:
>>
>> % ssh -F ssh_config test-|BR.foo.bar
>>
>> The characters being inserted seem to come from the "bar".
>>
>> With ".dot.com" at the end I am seeing "CM" being inserted.
>>
>> With "Host test-05.dot.com test-6c.dot.com" however "D" is being
>> inserted.
>>
>> And with a single TLD (i.e. "test-05827d88.com test-6cae9ce0.com") it
>> works.
>>
>> In _ssh_hosts the following is used, which seems to be relevant, since
>> the inserted characters are uppercased:
>>
>>     compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts
>>
>> zsh 5.2-dev-1, 062aeca.
>>
>>
>> Thanks,
>> Daniel.
>>
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

  reply	other threads:[~2016-08-17 22:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 19:16 Daniel Hahler
2016-08-17 19:38 ` Daniel Hahler
2016-08-17 22:52   ` Daniel Hahler [this message]
2016-08-18  5:32     ` Bart Schaefer
2016-08-17 22:36 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=174db3fa-2af2-d43b-3978-5cb789af4ed9@thequod.de \
    --to=genml+zsh-workers@thequod.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).