# pkgrm completion -*- shell-script -*- # # Copyright 2006 Yann Rouillard _have pkgrm && proc _pkgrm { local cur prev words cword _init_completion || return # if a spool directory was given # we must complete with the package # available in this directory local spool=/var/sadm/pkg; local i=$cword { setglobal i = $shExpr('i-1'); match $(words[$i]) { with -s setglobal spool = $(words[$((i+1))]); break }; }; match $prev { with -a | -V _filedir with -s | -R _filedir -d with -Y with * if [[ ${cur} == -* ]] { local opts="-a -A -n -M -R -s -v -V -Y"; setglobal COMPREPLY = ''($(compgen -W "${opts}" -- ${cur})); return 0; } else { setglobal COMPREPLY = ''($(compgen -W "$(/bin/ls -1 $spool)" -- ${cur})); return 0; } } } && complete -F _pkgrm pkgrm # ex: ts=4 sw=4 et filetype=sh