Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: return value for comp{add,gen}



( I just accidentally typed C-c C-c too early... )

I wrote:

> The patch below makes `compadd' and `compgen' return zero if matches
> were added and non-zero otherwise. With that Andrej's proposed
> 
>   compgen -g '*.c' || compgen -f
> 
> works.

I have not changed the return value since I think the `compctl was
found' is the most important think to know about when using it. And
since this will be called in a rather top-levellish way in most cases, 
the simple test `(( compstate[nmatches] ))' should be enough.

Also, I'm not too sure about the `compstate[last_nmatches]' Andrej
suggested. The exact number is seldom of interest and if it is, the
shell code is simple enough, I think.

As for the convention of using `matches were added' as the condition
to set the return values of the example functions: yes, I like
this. After a somwhat cursory glance at some of the function I even
think that this wouldn't required too many changes (since most
functions call `comp{add,gen}' or helper functions like `_files' at
the end).

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author