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

Re: "invalid arguments" in cpio completion



Danek Duvall wrote on Thu, Nov 03, 2016 at 13:32:56 -0700:
>     $ cpio -p <TAB>
>     _arguments:comparguments:313: invalid argument: 
> 

In HEAD I get filename completion at this point, regardless of whether
I choose the 'gnu' or 'unix' variant.

> That seems to be coming from this oddity:
> 
>     $ local args
>     $ args+=(a b c)
>     $ print -l -- "$args[@]"
> 
>     a
>     b
>     c
> 

This behaviour is the same in HEAD.

> But explicitly declaring args as an array makes it work:
⋮
> and making that change in _cpio makes the completion work.  I'm just not
> sure if the += construct on a scalar is supposed to make any sense here.

Will fix.

Cheers,

Daniel


diff --git a/Completion/Unix/Command/_cpio b/Completion/Unix/Command/_cpio
index 4027cc0..699b1d8 100644
--- a/Completion/Unix/Command/_cpio
+++ b/Completion/Unix/Command/_cpio
@@ -1,6 +1,7 @@
 #compdef cpio
 
-local args ig curcontext="$curcontext" state line
+local -a args
+local ig curcontext="$curcontext" state line
 local expl ret=1
 local fmts='(bar bin odc newc crc tar ustar hpbin hpodc)'
 



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