Use numeric comparison operators when comparing numerically.

This commit is contained in:
Ville Skyttä 2011-02-10 23:55:16 +02:00
parent 6042cbe2f5
commit 344076f92c
8 changed files with 14 additions and 12 deletions

View File

@ -40,7 +40,7 @@ _chown()
# The first argument is an usergroup; the rest are filedir. # The first argument is an usergroup; the rest are filedir.
_count_args : _count_args :
if [[ $args == 1 ]]; then if [[ $args -eq 1 ]]; then
_usergroup -u _usergroup -u
else else
_filedir _filedir

View File

@ -32,7 +32,7 @@ _dpkg()
# find the last option flag # find the last option flag
if [[ $cur != -* ]]; then if [[ $cur != -* ]]; then
while [[ $prev != -* && $i != 1 ]]; do while [[ $prev != -* && $i -ne 1 ]]; do
i=$((i-1)) i=$((i-1))
prev=${COMP_WORDS[i-1]} prev=${COMP_WORDS[i-1]}
done done

View File

@ -5,7 +5,7 @@
have find && have find &&
_find() _find()
{ {
local cur prev i exprfound onlyonce local cur prev i onlyonce
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref cur prev _get_comp_words_by_ref cur prev
@ -68,13 +68,15 @@ _find()
esac esac
_expand || return 0 _expand || return 0
# set exprfound to 1 if there is already an expression present
local exprfound=false
# set exprfound to true if there is already an expression present
for i in ${COMP_WORDS[@]}; do for i in ${COMP_WORDS[@]}; do
[[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break [[ "$i" = [-\(\),\!]* ]] && exprfound=true && break
done done
# handle case where first parameter is not a dash option # handle case where first parameter is not a dash option
if [[ "$exprfound" != 1 && "$cur" != [-\(\),\!]* ]]; then if ! $exprfound && [[ "$cur" != [-\(\),\!]* ]]; then
_filedir -d _filedir -d
return 0 return 0
fi fi

View File

@ -8,7 +8,7 @@ _jar()
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref cur _get_comp_words_by_ref cur
if [ $COMP_CWORD = 1 ]; then if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'c t x u' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'c t x u' -- "$cur" ) )
return 0 return 0
fi fi

View File

@ -102,7 +102,7 @@ _postcat()
for idx in "${COMP_WORDS[@]}"; do for idx in "${COMP_WORDS[@]}"; do
[[ "$idx" = -q ]] && qfile=1 && break [[ "$idx" = -q ]] && qfile=1 && break
done done
if [[ $qfile == 1 ]]; then if [[ $qfile -eq 1 ]]; then
len=${#cur} len=${#cur}
idx=0 idx=0
for pval in $( mailq 2>/dev/null | \ for pval in $( mailq 2>/dev/null | \

View File

@ -156,7 +156,7 @@ _sysbench()
if [[ "$cur" == -* || ! $test ]]; then if [[ "$cur" == -* || ! $test ]]; then
COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
[[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \ [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} != *= ]] && \
compopt +o nospace &>/dev/null compopt +o nospace &>/dev/null
else else
compopt +o nospace &>/dev/null compopt +o nospace &>/dev/null

View File

@ -61,7 +61,7 @@ _look()
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref cur _get_comp_words_by_ref cur
if [ $COMP_CWORD = 1 ]; then if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) )
fi fi
} && } &&

View File

@ -51,7 +51,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[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \ [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} != *= ]] && \
compopt +o nospace &>/dev/null compopt +o nospace &>/dev/null
fi fi
;; ;;
@ -104,7 +104,7 @@ _cdrecord()
COMPREPLY=( "${COMPREPLY[@]}" \ COMPREPLY=( "${COMPREPLY[@]}" \
$( compgen -W '${generic_options[@]}' -- "$cur" ) ) $( compgen -W '${generic_options[@]}' -- "$cur" ) )
fi fi
[[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \ [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} != *= ]] && \
compopt +o nospace &>/dev/null compopt +o nospace &>/dev/null
} && } &&
complete -F _cdrecord -o nospace cdrecord wodim complete -F _cdrecord -o nospace cdrecord wodim