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

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



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.



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