zsh-workers
 help / color / mirror / code / Atom feed
* [BUG/RFC] IPv6 host:port completion needs work
@ 2019-02-05 20:01 dana
  2019-02-11 17:25 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: dana @ 2019-02-05 20:01 UTC (permalink / raw)
  To: Zsh workers

I was working on a host:port completion bug someone mentioned on IRC, and i
decided that it would probably be useful to have a dedicated _hosts_ports
function due to the special bracketed syntax that IPv6 uses, which can't
(AFAIK) be handled properly by _combination alone.

My first attempt at that function is simply this:

  if compset -P '([^\[:]##|\[?*\]):'; then
    _ports "$@"
  else
    [[ $PREFIX$SUFFIX != \[* || $PREFIX$SUFFIX == *\]* ]] && compset -S ':[^:.]#'
    compset -P '\['
    compset -S '\]'
    _hosts "$@" -qS:
  fi

Which works OK, except that we need to actually include the brackets when
offering IPv6 addresses. I think compadd's -p and -s options would normally be
useful here, but they're unconditional.

I could update _hosts itself to take an option telling it to do two compadd
passes, one with -p\[ -s\] (for hosts matching *:*) and one without (for the
rest). That's similar in concept to what i did to _bind_addresses for
workers/43207. But is that the best way? Am i overlooking something?

dana


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [BUG/RFC] IPv6 host:port completion needs work
  2019-02-05 20:01 [BUG/RFC] IPv6 host:port completion needs work dana
@ 2019-02-11 17:25 ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2019-02-11 17:25 UTC (permalink / raw)
  To: dana; +Cc: Zsh workers

On 5 Feb, dana wrote:
> I could update _hosts itself to take an option telling it to do two compadd
> passes, one with -p\[ -s\] (for hosts matching *:*) and one without (for the
> rest). That's similar in concept to what i did to _bind_addresses for
> workers/43207. But is that the best way? Am i overlooking something?

Yes, the approach taken in _bind_addresses where -b indicates that
IPv6 addresses need quoting with square brackets seems good to me.
_hosts_ports could also accept it and pass it on down.

Oliver

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-11 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-05 20:01 [BUG/RFC] IPv6 host:port completion needs work dana
2019-02-11 17:25 ` Oliver Kiddle

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).