zsh-workers
 help / 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, back to index

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

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/ public-inbox