Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible to use _arguments with _regex_arguments?
- X-seq: zsh-users 24260
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: "Ronan Pigott" <rpigott314@xxxxxxxxx>
- Subject: Re: Possible to use _arguments with _regex_arguments?
- Date: Wed, 18 Sep 2019 23:32:14 +0200
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1568842337; bh=gMPOlZxWGO860KSlqHeJ8kc39hf4JTDgfAJfFUN6LZg=; h=From:References:To:Subject:Date:From:Subject; b=UbWXjzQ2r0iyoXnqMKtOCN2NApz/GjnigwWe+rsVLqEB1oYhwMUxDCMD8vSslP8N7c2PSe+bOuH962jsOu5WYXCCdTTXp5jjkaetywGXWUWGyr4OhiUU1Nkevqidt92yJ0yH6ULfGvWOM+y6CYVLVnpMM+3+LEE0QTtGjp+XFEfUriNfCWx4ujlPF4x0DfMAp8tH/Cmi7gjVM8n+tOrlU/rSEVApkBj8qh2tkEGFKqZnKy3HDQteW+OEzF86nw24SslK/eHxlxcPrrujXHLlpL0RQZq+xB9rZUtk1Kwoh4VwE+xNlc253tHhYfOX/MyF2eFBy7PiOhkaRitXodG5zg==
- In-reply-to: <BX3EOWYQ1AY8.LBR42DF8EFH7@rxps>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <BX3EOWYQ1AY8.LBR42DF8EFH7@rxps>
"Ronan Pigott" wrote:
> I've since found that _arguments itself has the ability to transform the
> words and CURRENT special parameters by specifying the argument like:
> '*::message:action', but unfortunately it still does not produce the
> desired result when 'action' is a function generated by
> _regex_arguments. Can anyone explain the behavior I see?
Both _arguments and _regex_arguments like the words array to start with
an initial element for the command. With '*:message:action', the -o
options get left in $words. With the '*::... form, they are stripped but
there is no initial element left. Try using
'*::positional arguments:= _myfunc'
More specifically:
_regex_arguments _myfunc /$'*\0[ \t\n]#'/ \
'/[]/' ':args:arg:(one two three)'
_arguments -S -s \
{-o+,--option}'[an option]:tag:(some values)' \
'*::positional arguments:= _myfunc'
The = causes it to add back an initial element in $words.
_regex_arguments is then ignoring this with the /$'*\0[ \t\n]#'/ pattern
so this is all fairly pointless but _regex_arguments was somehow
designed for handling the whole command-line.
If you'd like to see a real example that combines _arguments with
_regex_arguments see _sed from a relatively recent zsh.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author