- wvdial patch from Guillaume Rousse <rousse@ccr.jussieu.fr>

This commit is contained in:
ianmacd 2003-12-31 23:51:46 +00:00
parent 408553e471
commit 3eb3e5724b

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05b
#
# $Id: bash_completion,v 1.668 2004/01/01 00:48:05 ianmacd Exp $
# $Id: bash_completion,v 1.669 2004/01/01 00:51:46 ianmacd Exp $
#
# Copyright (C) Ian Macdonald <ian@caliban.org>
#
@ -4859,7 +4859,7 @@ _dcop()
have wvdial &&
_wvdial()
{
local cur prev configfile i
local cur prev config i IFS=$'\t\n'
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
@ -4875,21 +4875,26 @@ _wvdial()
case $cur in
-*)
COMPREPLY=( $( compgen -W '--config --chat \
--remotename --help --version --no-syslog' -- $cur ) )
--remotename --help --version --no-syslog' \
-- $cur ) )
;;
*)
# find which config file to use
configfile=/etc/wvdial.conf
# start with global and personal config files
config="/etc/wvdial.conf"$'\t'"$HOME/.wvdialrc"
# replace with command line config file if present
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == $1 ]]; then
configfile=${COMP_WORDS[i+1]}
if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
config=${COMP_WORDS[i+1]}
break
fi
done
[ ! -f $configfile ] && return 0
# parse config file for sections
COMPREPLY=( $( awk '/\[Dialer .+\]/ {print $0}' $configfile |\
sed -e '1d' -e 's/^\[Dialer //' -e 's/\]$//' | grep "^$cur" ) )
# parse config files for sections and
# remove default section
COMPREPLY=( $( sed -ne \
"s|^\[Dialer \($cur.*\)\]$|\1|p" \
$config 2>/dev/null |grep -v '^Defaults$'))
# escape spaces
COMPREPLY=${COMPREPLY// /\\ }
;;
esac