Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[BUG/RFC] IPv6 host:port completion needs work



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



Messages sorted by: Reverse Date, Date, Thread, Author