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