Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: outputs of _users and _hosts to arrays
- X-seq: zsh-users 9143
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: outputs of _users and _hosts to arrays
- Date: Sun, 24 Jul 2005 09:33:14 +0000
- In-reply-to: <DC95ADD4-4F3C-4024-A9BE-242EC503D12C@xxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <DC95ADD4-4F3C-4024-A9BE-242EC503D12C@xxxxxxxxxxxxxxxxxxxx>
On Jul 24, 4:05pm, Wataru Kagawa wrote:
}
} How can I add the outputs of _users and _hosts to arrays?
Those are completion functions. They don't have output. They just
call the compadd builtin.
So look up "compadd" in the manual, and you find:
-O ARRAY
If this option is given, the WORDS are _not_ added to the set
of possible completions. Instead, matching is done as usual
and all of the WORDS given as arguments that match the string
on the command line will be stored in the array parameter
whose name is given as ARRAY.
And therefore:
_users -O users
_hosts -O hosts
However, that only works inside functions called by the completion code.
You cannot employ _users and _hosts for generalized programming.
} users=( "$_users[@]" )
} hosts=( "$_hosts[@]" )
That syntax would mean that _users and _hosts were array variables; but
you seem to know that they're functions, so why did you try that?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author