On 01/11/2018 11:48 AM, Martin Kletzander wrote:
On Tue, Jan 02, 2018 at 06:11:57PM +0100, Michal Privoznik wrote:
> In the future, this function is going to be called from
> vshReadlineParse() to provide parsed input for completer
> callbacks. The idea is to allow the callbacks to provide more
> specific data. For instance, for the following input:
>
> virsh # domifaddr --domain fedora --interface <TAB><TAB>
>
> the --interface completer callback is going to be called. Now, it
> is more user friendly if the completer offers only those
> interfaces found in 'fedora' domain. But in order to do that it
> needs to be able to retrieve partially parsed result.
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
> ---
> tools/virsh.c | 4 +-
> tools/virt-admin.c | 4 +-
> tools/vsh.c | 111
> +++++++++++++++++++++++++++++++++++++----------------
> tools/vsh.h | 2 +-
> 4 files changed, 82 insertions(+), 39 deletions(-)
>
> diff --git a/tools/vsh.c b/tools/vsh.c
> index 2366b7b71..34eb592ef 100644
> --- a/tools/vsh.c
> +++ b/tools/vsh.c
> @@ -1519,11 +1544,12 @@ vshCommandParse(vshControl *ctl,
> vshCommandParser *parser)
> last->next = arg;
> last = arg;
>
> - vshDebug(ctl, VSH_ERR_INFO, "%s: %s(%s): %s\n",
> - cmd->name,
> - opt->name,
> - opt->type != VSH_OT_BOOL ? _("optdata") :
> _("bool"),
> - opt->type != VSH_OT_BOOL ? arg->data :
> _("(none)"));
> + if (ctl)
Don't you mean (!partial) here? This change looks weird otherwise.
Oh right.
After reading the following patches I see that you call this with ctl ==
NULL
(from readline). That makes sense, but there are few more places where
ctl is
used even when partial != NULL and that needs to be handled correctly.
Like what? vshError() can handle if ctl is NULL, and subsequently
vshMalloc(), vshStrdup(), vshCmddefGetOption() and vshCommandCheckOpts()
can too.
Michal