- find(1) completion improvements by Rodrigo Bernardo Pimentel
<rbp@isnomore.net>
This commit is contained in:
parent
1d45ccd703
commit
b2a7765b00
@ -1,6 +1,6 @@
|
|||||||
# bash_completion - some programmable completion functions for bash 2.05b
|
# 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 <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -791,7 +791,7 @@ _killall()
|
|||||||
#
|
#
|
||||||
_find()
|
_find()
|
||||||
{
|
{
|
||||||
local cur prev i switchfound
|
local cur prev i exprfound onlyonce
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
@ -843,13 +843,13 @@ _find()
|
|||||||
|
|
||||||
_expand || return 0
|
_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
|
for i in ${COMP_WORDS[@]}; do
|
||||||
[[ "$i" = -* ]] && switchfound=1 && break
|
[[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
|
||||||
done
|
done
|
||||||
|
|
||||||
# handle case where first parameter is not a dash option
|
# handle case where first parameter is not a dash option
|
||||||
if [ "$switchfound" != 1 ] && [[ "$cur" != -* ]]; then
|
if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
|
||||||
_filedir -d
|
_filedir -d
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -865,10 +865,16 @@ _find()
|
|||||||
-print -print0 -printf -prune -ls' -- $cur ) )
|
-print -print0 -printf -prune -ls' -- $cur ) )
|
||||||
|
|
||||||
# this removes any options from the list of completions that have
|
# 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[@]}" | \
|
COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
|
||||||
(while read -d ' ' i; do
|
(while read -d ' ' i; do
|
||||||
[ "$i" == "" ] && continue
|
[ "$i" == "" ] ||
|
||||||
|
[ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
|
||||||
|
continue
|
||||||
# flatten array with spaces on either side,
|
# flatten array with spaces on either side,
|
||||||
# otherwise we cannot grep on word boundaries of
|
# otherwise we cannot grep on word boundaries of
|
||||||
# first and last word
|
# first and last word
|
||||||
|
Loading…
x
Reference in New Issue
Block a user