avoid use of extra file descriptor and grep in _file_and_dir by using
parameter substitutions
This commit is contained in:
parent
2c4236d117
commit
1aa894b7dd
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# <![CDATA[
|
# <![CDATA[
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.37 2001/12/20 08:52:12 ianmacd Exp $
|
# $Id: bash_completion,v 1.38 2001/12/20 17:12:44 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -1435,26 +1435,25 @@ _file_and_dir()
|
|||||||
|
|
||||||
COMPREPLY=( $( eval compgen -f -X "$xspec" $cur ) $( compgen -d $cur ) )
|
COMPREPLY=( $( eval compgen -f -X "$xspec" $cur ) $( compgen -d $cur ) )
|
||||||
}
|
}
|
||||||
|
list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
|
||||||
|
/etc/bash_completion | \
|
||||||
# read exclusion compspecs
|
# read exclusion compspecs
|
||||||
IFS=$'\n'
|
(
|
||||||
exec 3< /etc/bash_completion
|
while read line
|
||||||
while read line <&3
|
|
||||||
do
|
do
|
||||||
# only parse relevant section
|
line=${line%# START exclude*}
|
||||||
echo $line | grep -q '^# START exclude' && found=1 && read line <&3
|
line=${line%# FINISH exclude*}
|
||||||
[ -z "$found" ] && continue
|
|
||||||
echo $line | grep -q '^# FINISH exclude' && break
|
|
||||||
# leave only names of commands for which to make a compspec
|
|
||||||
line=${line##*\'}
|
line=${line##*\'}
|
||||||
list=( ${list[@]} $line )
|
list=( ${list[@]} $line )
|
||||||
done
|
done
|
||||||
exec 3<&-
|
echo ${list[@]}
|
||||||
IFS=$' \t\n'
|
)
|
||||||
|
) )
|
||||||
# remove previous compspecs
|
# remove previous compspecs
|
||||||
eval complete -r ${list[@]}
|
eval complete -r ${list[@]}
|
||||||
# install new compspecs
|
# install new compspecs
|
||||||
eval complete -F _file_and_dir -o filenames ${list[@]}
|
eval complete -F _file_and_dir -o filenames ${list[@]}
|
||||||
unset line found list[@]
|
unset list[@]
|
||||||
|
|
||||||
# source user completion file
|
# source user completion file
|
||||||
[ -f ~/.bash_completion ] && . ~/.bash_completion
|
[ -f ~/.bash_completion ] && . ~/.bash_completion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user