Various mostly array element unsetting fixes under failglob

This commit is contained in:
Ville Skyttä 2014-06-03 23:09:56 +03:00
parent 84135d756b
commit 1ed2377c89
9 changed files with 16 additions and 16 deletions

View File

@ -19,7 +19,7 @@ _badblocks()
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
# Filter out -w (dangerous) and -X (internal use) # Filter out -w (dangerous) and -X (internal use)
for i in ${!COMPREPLY[@]}; do for i in ${!COMPREPLY[@]}; do
[[ ${COMPREPLY[i]} == -[wX] ]] && unset COMPREPLY[i] [[ ${COMPREPLY[i]} == -[wX] ]] && unset 'COMPREPLY[i]'
done done
return 0 return 0
fi fi

View File

@ -18,19 +18,19 @@ _crontab()
local i local i
for (( i=0; i < ${#words[@]}-1; i++ )); do for (( i=0; i < ${#words[@]}-1; i++ )); do
[[ ${words[i]} ]] && unset opts[${words[i]}] [[ ${words[i]} ]] && unset "opts[${words[i]}]"
case "${words[i]}" in case "${words[i]}" in
-l) -l)
unset opts[-r] opts[-e] opts[-i] opts[-s] unset 'opts[-r]' 'opts[-e]' 'opts[-i]' 'opts[-s]'
;; ;;
-e) -e)
unset opts[-l] opts[-r] opts[-i] unset 'opts[-l]' 'opts[-r]' 'opts[-i]'
;; ;;
-r) -r)
unset opts[-l] opts[-e] unset 'opts[-l]' 'opts[-e]'
;; ;;
-u) -u)
unset opts[-i] unset 'opts[-i]'
;; ;;
esac esac
done done

View File

@ -156,11 +156,11 @@ _cvs()
local f local f
for i in ${!files[@]}; do for i in ${!files[@]}; do
if [[ ${files[i]} == ?(*/)CVS ]]; then if [[ ${files[i]} == ?(*/)CVS ]]; then
unset files[i] unset 'files[i]'
else else
for f in "${entries[@]}"; do for f in "${entries[@]}"; do
if [[ ${files[i]} == $f && ! -d $f ]]; then if [[ ${files[i]} == $f && ! -d $f ]]; then
unset files[i] unset 'files[i]'
break break
fi fi
done done
@ -337,7 +337,7 @@ _cvs()
if [[ "$prev" != -f ]]; then if [[ "$prev" != -f ]]; then
# find out what files are missing # find out what files are missing
for i in ${!entries[@]}; do for i in ${!entries[@]}; do
[[ -r "${entries[i]}" ]] && unset entries[i] [[ -r "${entries[i]}" ]] && unset 'entries[i]'
done done
fi fi
COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) )

View File

@ -101,7 +101,7 @@ _find()
for i in "${words[@]}"; do for i in "${words[@]}"; do
[[ $i && ${onlyonce[$i]} ]] || continue [[ $i && ${onlyonce[$i]} ]] || continue
for j in ${!COMPREPLY[@]}; do for j in ${!COMPREPLY[@]}; do
[[ ${COMPREPLY[j]} == $i ]] && unset COMPREPLY[j] [[ ${COMPREPLY[j]} == $i ]] && unset 'COMPREPLY[j]'
done done
done done
fi fi

View File

@ -62,7 +62,7 @@ _info()
COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
# weed out info dir file # weed out info dir file
for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
[[ ${COMPREPLY[$i]} == dir ]] && unset COMPREPLY[$i] [[ ${COMPREPLY[$i]} == dir ]] && unset "COMPREPLY[$i]"
done done
# strip suffix from info pages # strip suffix from info pages
COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} ) COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} )

View File

@ -20,7 +20,7 @@ _lvm_logicalvolumes()
_filedir _filedir
local i local i
for i in ${!COMPREPLY[@]}; do for i in ${!COMPREPLY[@]}; do
[[ ${COMPREPLY[i]} == */control ]] && unset COMPREPLY[i] [[ ${COMPREPLY[i]} == */control ]] && unset 'COMPREPLY[i]'
done done
fi fi
} }

View File

@ -84,7 +84,7 @@ _modprobe()
for i in ${!mods[@]}; do for i in ${!mods[@]}; do
for module in ${COMPREPLY[@]}; do for module in ${COMPREPLY[@]}; do
if [[ ${mods[i]} == $module ]]; then if [[ ${mods[i]} == $module ]]; then
unset mods[i] unset 'mods[i]'
break break
fi fi
done done

View File

@ -49,7 +49,7 @@ _protoc()
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
local i local i
for i in ${!COMPREPLY[@]}; do for i in ${!COMPREPLY[@]}; do
[[ ${COMPREPLY[i]} == -oFILE ]] && unset COMPREPLY[i] [[ ${COMPREPLY[i]} == -oFILE ]] && unset 'COMPREPLY[i]'
done done
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace
return return

View File

@ -5,9 +5,9 @@ _qdbus()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
[[ -n $cur ]] && unset words[${#words[@]}-1] [[ -n $cur ]] && unset "words[$((${#words[@]}-1))]"
COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \ COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \
sed s/\(.*\)// )' -- "$cur" ) ) sed "s/(.*)//" )' -- "$cur" ) )
} && } &&
complete -F _qdbus qdbus dcop complete -F _qdbus qdbus dcop