diff --git a/bash_completion b/bash_completion index efb7c245..e733f199 100644 --- a/bash_completion +++ b/bash_completion @@ -2,7 +2,7 @@ # # # @@ -381,10 +381,11 @@ complete -F _killall killall # _find() { - local cur prev i + local cur ncur prev i COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]#-} + cur=${COMP_WORDS[COMP_CWORD]#} + ncur=${cur#-} prev=${COMP_WORDS[COMP_CWORD-1]} case "$prev" in @@ -393,34 +394,34 @@ _find() return 0 ;; -?(a)newer|-fls|-fprint?(0|f)) - COMPREPLY=( $( compgen -f $cur ) ) + COMPREPLY=( $( compgen -f $ncur ) ) return 0 ;; -fstype) # this is highly non-portable - COMPREPLY=( $( cut -d$'\t' -f 2 /proc/filesystems | grep ^$cur ) ) + COMPREPLY=( $( cut -d$'\t' -f 2 /proc/filesystems | grep ^$ncur ) ) return 0 ;; -gid) COMPREPLY=( $( awk 'BEGIN {FS=":"} \ - {if ($3 ~ /^'$cur'/) print $3}' /etc/group ) ) + {if ($3 ~ /^'$ncur'/) print $3}' /etc/group ) ) return 0 ;; -group) - COMPREPLY=( $( compgen -g $cur ) ) + COMPREPLY=( $( compgen -g $ncur ) ) return 0 ;; -?(x)type) - COMPREPLY=( $( compgen -W 'b c d p f l s' $cur ) ) + COMPREPLY=( $( compgen -W 'b c d p f l s' $ncur ) ) return 0 ;; -uid) COMPREPLY=( $( awk 'BEGIN {FS=":"} \ - {if ($3 ~ /^'$cur'/) print $3}' /etc/passwd ) ) + {if ($3 ~ /^'$ncur'/) print $3}' /etc/passwd ) ) return 0 ;; -user) - COMPREPLY=( $( compgen -u $cur ) ) + COMPREPLY=( $( compgen -u $ncur ) ) return 0 ;; -[acm]min|-[acm]time|-?(i)?(l)name|-inum|-?(i)path|-?(i)regex| \ @@ -432,7 +433,13 @@ _find() _expand || return 0 - # complete using basic options ($cur has had its dash removed here, + # handle case where first parameter is not a dash option + if [ $COMP_CWORD = 1 -a "$cur" = "$ncur" ]; then + COMPREPLY=( $( compgen -d $cur ) ) + return 0 + fi + + # complete using basic options ($ncur has had its dash removed here, # as otherwise compgen will bomb out with an error, since it thinks # the dash is an option to itself) COMPREPLY=( $( compgen -W 'daystart depth follow help maxdepth \ @@ -441,7 +448,7 @@ _find() iname inum ipath iregex links lname mmin mtime name \ newer nouser nogroup perm regex size true type uid \ used user xtype exec fls fprint fprint0 fprintf ok \ - print print0 printf prune ls' $cur ) ) + print print0 printf prune ls' $ncur ) ) # this removes any options from the list of completions that have # already been specified somewhere on the command line.