zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Update _bind_addresses to work with new ifconfig output (and old).
@ 2011-12-10 19:32 Mikael Magnusson
  2011-12-10 20:14 ` Danek Duvall
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2011-12-10 19:32 UTC (permalink / raw)
  To: zsh-workers

I updated net-tools just before sending out the ssh patches and couldn't
quite work out why the -L and -R completions didn't work anymore, turns
out the ifconfig output changed from

eth0      Link encap:Ethernet  HWaddr xx:xx
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0

to

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255

This patch changes the pattern to work with either output format by
checking for the inet keyword instead of addr.

---
 Completion/Unix/Type/_bind_addresses |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Completion/Unix/Type/_bind_addresses b/Completion/Unix/Type/_bind_addresses
index 606de3f..cbe7be2 100644
--- a/Completion/Unix/Type/_bind_addresses
+++ b/Completion/Unix/Type/_bind_addresses
@@ -11,5 +11,5 @@ case $OSTYPE in
   linux*) ;&
   *)
     _wanted bind-addresses expl 'bind address' compadd "$@" - \
-      ${${${(M)${(f)"$(ifconfig -a)"}:#*addr:*}##*addr:}%% *}
+      ${${${(M)${(f)"$(ifconfig -a)"}:#*inet*}##*inet (addr:)(#c0,1)}%% *}
 esac
-- 
1.7.5.4


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

* Re: PATCH: Update _bind_addresses to work with new ifconfig output (and old).
  2011-12-10 19:32 PATCH: Update _bind_addresses to work with new ifconfig output (and old) Mikael Magnusson
@ 2011-12-10 20:14 ` Danek Duvall
  2011-12-10 20:26   ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Danek Duvall @ 2011-12-10 20:14 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: zsh-workers

On Sat, Dec 10, 2011 at 08:32:52PM +0100, Mikael Magnusson wrote:

> diff --git a/Completion/Unix/Type/_bind_addresses b/Completion/Unix/Type/_bind_addresses
> index 606de3f..cbe7be2 100644
> --- a/Completion/Unix/Type/_bind_addresses
> +++ b/Completion/Unix/Type/_bind_addresses
> @@ -11,5 +11,5 @@ case $OSTYPE in
>    linux*) ;&
>    *)
>      _wanted bind-addresses expl 'bind address' compadd "$@" - \
> -      ${${${(M)${(f)"$(ifconfig -a)"}:#*addr:*}##*addr:}%% *}
> +      ${${${(M)${(f)"$(ifconfig -a)"}:#*inet*}##*inet (addr:)(#c0,1)}%% *}
>  esac

If you put a space after "inet" and before the star, it'll work when you
have ipv6 addresses (at least on Solaris, whose ifconfig has the new output
you show).  Otherwise, you get "inet6" as a completion, which is a bit
silly.  Of course, you don't get the actual ipv6 addresses, but that's
probably not a big priority yet.

Danek


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

* Re: PATCH: Update _bind_addresses to work with new ifconfig output (and old).
  2011-12-10 20:14 ` Danek Duvall
@ 2011-12-10 20:26   ` Mikael Magnusson
  2011-12-10 22:18     ` Danek Duvall
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2011-12-10 20:26 UTC (permalink / raw)
  To: Danek Duvall, zsh-workers

On 10 December 2011 21:14, Danek Duvall <duvall@comfychair.org> wrote:
> On Sat, Dec 10, 2011 at 08:32:52PM +0100, Mikael Magnusson wrote:
>
>> diff --git a/Completion/Unix/Type/_bind_addresses b/Completion/Unix/Type/_bind_addresses
>> index 606de3f..cbe7be2 100644
>> --- a/Completion/Unix/Type/_bind_addresses
>> +++ b/Completion/Unix/Type/_bind_addresses
>> @@ -11,5 +11,5 @@ case $OSTYPE in
>>    linux*) ;&
>>    *)
>>      _wanted bind-addresses expl 'bind address' compadd "$@" - \
>> -      ${${${(M)${(f)"$(ifconfig -a)"}:#*addr:*}##*addr:}%% *}
>> +      ${${${(M)${(f)"$(ifconfig -a)"}:#*inet*}##*inet (addr:)(#c0,1)}%% *}
>>  esac
>
> If you put a space after "inet" and before the star, it'll work when you
> have ipv6 addresses (at least on Solaris, whose ifconfig has the new output
> you show).  Otherwise, you get "inet6" as a completion, which is a bit
> silly.  Of course, you don't get the actual ipv6 addresses, but that's
> probably not a big priority yet.

Thanks, I've updated the patch. Does it complete ipv6 addresses if you
add 6(#c0,1) after the second inet instead?
${${${(M)${(f)"$(ifconfig -a)"}:#*inet*}##*inet6(#c0,1) (addr:)(#c0,1)}%% *}
But maybe if it's an inet6 it should also be surrounded by [], I'm not
super familiar with ipv6 and what programs expect since I don't use
it. At least ssh(1) mentions that you can do so in the contexts that
this completer is used in from _ssh. I do have access to a host with
ipv6 addresses, and those have a /64 or so without a space at the end
too, I guess that would have to be removed too then. Is it the same
with the new output? (That host has the old output).

-- 
Mikael Magnusson


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

* Re: PATCH: Update _bind_addresses to work with new ifconfig output (and old).
  2011-12-10 20:26   ` Mikael Magnusson
@ 2011-12-10 22:18     ` Danek Duvall
  0 siblings, 0 replies; 4+ messages in thread
From: Danek Duvall @ 2011-12-10 22:18 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: zsh-workers

On Sat, Dec 10, 2011 at 09:26:46PM +0100, Mikael Magnusson wrote:

> Thanks, I've updated the patch. Does it complete ipv6 addresses if you
> add 6(#c0,1) after the second inet instead?
> ${${${(M)${(f)"$(ifconfig -a)"}:#*inet*}##*inet6(#c0,1) (addr:)(#c0,1)}%% *}

Yes, but, as you saw, with the network prefix length, too.  Putting that
expression in ${...%/<->} seems to remove the length for me.

> But maybe if it's an inet6 it should also be surrounded by [], I'm not
> super familiar with ipv6 and what programs expect since I don't use it.

Yeah, I'm not positive what ssh expects here.  Looks like either

    [<address>]:<port>

or

    <address>/port

would work, which makes sense, as neither syntax is ambiguous.  But the ssh
on Solaris is forked from openssh, so I can't say how a pure openssh
implementation would be.

Danek


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

end of thread, other threads:[~2011-12-10 22:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-10 19:32 PATCH: Update _bind_addresses to work with new ifconfig output (and old) Mikael Magnusson
2011-12-10 20:14 ` Danek Duvall
2011-12-10 20:26   ` Mikael Magnusson
2011-12-10 22:18     ` Danek Duvall

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