No need to test for COMPREPLY count when toggling nospace.

It only takes effect if there's only one completion anyway.
This commit is contained in:
Ville Skyttä 2011-04-27 15:46:27 +03:00
parent 5cd5993211
commit 48ffb0ac6d
5 changed files with 9 additions and 17 deletions

View File

@ -78,8 +78,7 @@ _java_classes()
$( compgen -f -X '!*.class' -- "$i/$cur" | \ $( compgen -f -X '!*.class' -- "$i/$cur" | \
sed -e '/\$/d' -e "s|^$i/||" ) sed -e '/\$/d' -e "s|^$i/||" )
) )
[[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == *.class ]] && \ [[ $COMPREPLY == *.class ]] && compopt +o nospace &>/dev/null
compopt +o nospace &>/dev/null
# FIXME: if we have foo.class and foo/, the completion # FIXME: if we have foo.class and foo/, the completion
# returns "foo/"... how to give precedence to files # returns "foo/"... how to give precedence to files
@ -232,8 +231,7 @@ _java()
fi fi
fi fi
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == -*[:=] ]] && \ [[ $COMPREPLY == -*[:=] ]] && compopt -o nospace
compopt -o nospace
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
} && } &&
@ -380,8 +378,7 @@ _pack200()
--method-attribute= --code-attribute= --config-file= \ --method-attribute= --code-attribute= --config-file= \
--verbose --quiet --log-file= --help --version -J \ --verbose --quiet --log-file= --help --version -J \
--repack' -- "$cur" ) ) --repack' -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && \ [[ $COMPREPLY == *= ]] && compopt -o nospace
compopt -o nospace
else else
_filedir 'pack?(.gz)' _filedir 'pack?(.gz)'
fi fi
@ -425,8 +422,7 @@ _unpack200()
if [[ "$cur" == -* ]] ; then if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W '--deflate-hint= --remove-pack-file \ COMPREPLY=( $( compgen -W '--deflate-hint= --remove-pack-file \
--verbose --quiet --log-file= --help --version' -- "$cur" ) ) --verbose --quiet --log-file= --help --version' -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && \ [[ $COMPREPLY == *= ]] && compopt -o nospace
compopt -o nospace
else else
_filedir 'pack?(.gz)' _filedir 'pack?(.gz)'
fi fi

View File

@ -68,8 +68,7 @@ _rsync()
--write-batch= --only-write-batch= --read-batch= --protocol= \ --write-batch= --only-write-batch= --read-batch= --protocol= \
--iconv= --ipv4 --ipv6 --version --help --daemon --config= \ --iconv= --ipv4 --ipv6 --version --help --daemon --config= \
--no-detach' -- "$cur" ) ) --no-detach' -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} != *= ]] && \ [[ $COMPREPLY == *= ]] || compopt +o nospace
compopt +o nospace
;; ;;
*:*) *:*)
if declare -F _scp_remote_files &>/dev/null; then if declare -F _scp_remote_files &>/dev/null; then

View File

@ -78,8 +78,7 @@ _smartctl_test()
COMPREPLY=( $( compgen -W 'offline short long conveyance select, COMPREPLY=( $( compgen -W 'offline short long conveyance select,
select,redo select,next afterselect,on afterselect,off pending, select,redo select,next afterselect,on afterselect,off pending,
scttempint, vendor,' -- "$cur" ) ) scttempint, vendor,' -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && "${COMPREPLY[@]}" == *, ]] && \ [[ $COMPREPLY == *, ]] && compopt -o nospace
compopt -o nospace
} }
_smartctl_drivedb() _smartctl_drivedb()
{ {

View File

@ -134,8 +134,7 @@ _sysbench()
if [[ "$cur" == -* || ! $test ]]; then if [[ "$cur" == -* || ! $test ]]; then
COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} != *= ]] || \ [[ $COMPREPLY == *= ]] && compopt -o nospace
compopt -o nospace
else else
COMPREPLY=( $( compgen -W "prepare run cleanup help version" \ COMPREPLY=( $( compgen -W "prepare run cleanup help version" \
-- "$cur" ) ) -- "$cur" ) )

View File

@ -43,8 +43,7 @@ _cdrecord()
gigarec= audiomaster forcespeed noforcespeed speedread gigarec= audiomaster forcespeed noforcespeed speedread
nospeedread singlesession nosinglesession hidecdr nospeedread singlesession nosinglesession hidecdr
nohidecdr tattooinfo tattoofile=' -- "$cur" ) ) nohidecdr tattooinfo tattoofile=' -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} != *= ]] || \ [[ $COMPREPLY == *= ]] && compopt -o nospace
compopt -o nospace
fi fi
;; ;;
driver) driver)
@ -91,7 +90,7 @@ _cdrecord()
if [ $track_mode -eq 0 ]; then if [ $track_mode -eq 0 ]; then
COMPREPLY+=( $( compgen -W '${generic_options[@]}' -- "$cur" ) ) COMPREPLY+=( $( compgen -W '${generic_options[@]}' -- "$cur" ) )
fi fi
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} != *= ]] || compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace
} && } &&
complete -F _cdrecord cdrecord wodim complete -F _cdrecord cdrecord wodim