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

Re: possibly useful zsh_directory_name implementation



On 11 March 2011 17:33, Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Fri, 11 Mar 2011 16:25:14 +0000
> Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
>> +local func
>> +
>> +if [[ -n $functions[zsh_directory_name] || \
>> +  ${+zsh_directory_name_functions} -ne 0 ]] ; then
>> +  zsh_directory_name c && return 0
>> +  for func in $zsh_directory_name_functions; do
>> +    $func c && return 0
>> +  done
>> +  return 1
>
> Instantly after sending this, I realised it should try all functions and
> return status 0 or 1 based on whether any were successful.  I've
> submitted it in that form.

Can you really just call a bunch of completions in series and get a
useful result? The documentation still seems to imply running will
stop as soon as one hook returns 0 status.

More importantly, shouldn't you only run zsh_directory_name if that
function exists? As it is now, it will be run even if only the array
is defined. Also, why the mix of -n $foo and ${+foo}?

% ls ~[<tab>_dynamic_directory_name:8: command not found: zsh_directory_name

-- 
Mikael Magnusson



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