diff --git a/bash_completion b/bash_completion index 9bd4fa75..c43d9fa5 100644 --- a/bash_completion +++ b/bash_completion @@ -1,6 +1,6 @@ # bash_completion - some programmable completion functions for bash 2.05b # -# $Id: bash_completion,v 1.661 2003/12/15 09:42:50 ianmacd Exp $ +# $Id: bash_completion,v 1.662 2003/12/15 09:49:51 ianmacd Exp $ # # Copyright (C) Ian Macdonald # @@ -791,7 +791,7 @@ _killall() # _find() { - local cur prev i switchfound + local cur prev i exprfound onlyonce COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} @@ -843,13 +843,13 @@ _find() _expand || return 0 - # set switchfound to 1 if there is already a switch argument + # set exprfound to 1 if there is already an expression present for i in ${COMP_WORDS[@]}; do - [[ "$i" = -* ]] && switchfound=1 && break + [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break done # handle case where first parameter is not a dash option - if [ "$switchfound" != 1 ] && [[ "$cur" != -* ]]; then + if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then _filedir -d return 0 fi @@ -865,10 +865,16 @@ _find() -print -print0 -printf -prune -ls' -- $cur ) ) # this removes any options from the list of completions that have - # already been specified somewhere on the command line. + # already been specified somewhere on the command line, as long as + # these options can only be used once (in a word, "options", in + # opposition to "tests" and "actions", as in the find(1) manpage). + onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \ + -noleaf -version -xdev ' COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \ (while read -d ' ' i; do - [ "$i" == "" ] && continue + [ "$i" == "" ] || + [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] && + continue # flatten array with spaces on either side, # otherwise we cannot grep on word boundaries of # first and last word