From 3eb3e5724b0c605a2074865e4855b327d20a99ce Mon Sep 17 00:00:00 2001 From: ianmacd <> Date: Wed, 31 Dec 2003 23:51:46 +0000 Subject: [PATCH] - wvdial patch from Guillaume Rousse --- bash_completion | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/bash_completion b/bash_completion index 96e08d9f..63a0c896 100644 --- a/bash_completion +++ b/bash_completion @@ -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 # @@ -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