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

Re: device cannot be completed after "ip link show dev"



On Wed, Apr 01, 2015 at 08:47:44AM -0700, Bart Schaefer wrote:
> On Apr 1,  1:15pm, Peter Stephenson wrote:
> }
> } > And I have figured out this works:
> } > 
> } > subcmd_dev=(
> } > /$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ 
> } > -'if [[ $words[CURRENT-1] = dev ]];then false;else true;fi'
> } > ':interfaces:network interface:_net_interfaces'
> } > )
> } 
> } I didn't even know what format guards could take in general...
> 
> They're just passed to "eval" and the exit status checked.  If false,
> the pattern is presumed not to match.  The pattern is evaluated with
> backreferences enabled, so normally you'd refer to $match in the guard,
> but in this case maybe we want to examine previous words rather than
> the one to which the pattern is being applied.
> 
> subcmd_dev=(
>  /$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/
>  -'[[ $words[CURRENT-1] != dev ]]'
>  ':interfaces:network interface:_net_interfaces'
> )
> 
> should be equivalent, but I suspect we might really want to examine the
> whole array slice $words[2,CURRENT-1] to see if "dev" appears anywhere.

If using -'[[ $words[2,CURRENT-1] != *dev* ]]', then "dev" and "up"
won't be completed after dev (this is right, dev after dev is wrong
syntax), but there is a prase failed warning :

% ip link show dev em1 <tab>
parse failed before current word



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