Use compgen -W instead of grepping $cur in wireless-tools.

This commit is contained in:
Ville Skyttä 2009-06-12 20:12:47 +03:00
parent 42ca281cb7
commit 9a7c9804f2

View File

@ -24,10 +24,10 @@ _iwconfig()
essid) essid)
COMPREPLY=( $( compgen -W 'on off any' -- $cur ) ) COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
COMPREPLY=( "${COMPREPLY[@]}" \ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
$( iwlist ${COMP_WORDS[1]} scan | \ "$( iwlist ${COMP_WORDS[1]} scan | \
awk -F '"' '/ESSID/ {print $2}' | \ awk -F '\"' '/ESSID/ {print $2}' )" \
grep "^$cur" )) -- $cur ) )
fi fi
return 0 return 0
;; ;;
@ -36,49 +36,43 @@ _iwconfig()
return 0 return 0
;; ;;
channel) channel)
COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \ COMPREPLY=( $( compgen -W \
awk '/^[[:space:]]*Channel/ {print $2}' | \ "$( iwlist ${COMP_WORDS[1]} channel | \
grep "^$cur" ) ) awk '/^[[:space:]]*Channel/ {print $2}' )" \
-- $cur ) )
return 0 return 0
;; ;;
freq) freq)
COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \ COMPREPLY=( $( compgen -W \
awk '/^[[:space:]]*Channel/ {print $4"G"}' | \ "$( iwlist ${COMP_WORDS[1]} channel | \
grep "^$cur" ) ) awk '/^[[:space:]]*Channel/ {print $4\"G\"}')" \
-- $cur ) )
return 0 return 0
;; ;;
ap) ap)
COMPREPLY=( $( compgen -W 'on off any' -- $cur ) ) COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
COMPREPLY=( "${COMPREPLY[@]}" \ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
$( iwlist ${COMP_WORDS[1]} scan | \ "$( iwlist ${COMP_WORDS[1]} scan | \
awk -F ': ' '/Address/ {print $2}' | \ awk -F ': ' '/Address/ {print $2}' )" \
grep "^$cur" ) ) -- $cur ) )
fi fi
return 0 return 0
;; ;;
rate) rate)
COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) ) COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) )
COMPREPLY=( "${COMPREPLY[@]}" \ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
$( iwlist ${COMP_WORDS[1]} rate | \ "$( iwlist ${COMP_WORDS[1]} rate | \
awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \ awk '/^[[:space:]]*[0-9]/ {print $1\"M\"}' )" \
grep "^$cur" ) ) -- $cur ) )
return 0 return 0
;; ;;
rts) rts|frag)
COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) ) COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
return 0 return 0
;; ;;
frag) key|enc)
COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
return 0
;;
key)
COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
return 0
;;
enc)
COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) ) COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
return 0 return 0
;; ;;