Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] new completions for head and tail commands
- X-seq: zsh-workers 37001
- From: "Jun T." <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] new completions for head and tail commands
- Date: Wed, 28 Oct 2015 21:56:29 +0900
- In-reply-to: <CAH+w=7YOw0K=mntgwuAxxo3ovVpDnL9+_dPNHRGngRrex6_CBw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <B5E3ED95-7E9C-45C1-83C3-F14C383F01E6@kba.biglobe.ne.jp> <20151027203447.GB28241@tarsus.local2> <CAH+w=7YOw0K=mntgwuAxxo3ovVpDnL9+_dPNHRGngRrex6_CBw@mail.gmail.com>
On 2015/10/28, at 5:54, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Tue, Oct 27, 2015 at 1:34 PM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>> Jun T. wrote on Tue, Oct 27, 2015 at 22:44:47 +0900:
>>> + opts='-A "-*"'
>>> (snip)
>>> +_arguments -C -s -S $opts : $args '*:file:_files' && return 0
>>
>> Should that be ${=opts}?
>
> Or opts=(-A "-*") more likely.
Thanks.
I will commit/push with the fix opts=(-A "-*") (which I believe the
correct one). But there remains a behavior which I still don't understand.
Using opts=(-A "-*") is equivalent to
[1] _arguments -A '-*'
while ${=opts} may correspond to
[2] _arguments -A '"-*"'
i.e., the pattern includes double quotes. My original is equivalent to
[3] _arguments '-A "-*"'
which looks quite wrong but seems to (accidentally) work due to a strange
option parsing of _arguments (so I didn't notice the error while testing).
All of the above work in the sense that, on non-gnu systems,
% tail file1 -<TAB>
does not complete any options. But if there is a file whose name starts
with a '-' (say, '-abc'), then [2][3] behave differently from [1].
With [2] or [3], the <TAB> completes the file name '-abc', while with [1]
nothing is offered (I get a message 'no more arguments' due to a setting
in my .zshrc). The same applies to
% tail -- -<TAB>
I'm not sure whether the behavior of [1] (not offering '-abc') is the
expected one or not, and have no idea why '-abc' is offered by [2][3].
Messages sorted by:
Reverse Date,
Date,
Thread,
Author