[Bash-completion-commits] [SCM] bash-completion branch, master, updated. cc66ec76f593cc7f15105917b565731c061c68ab
Ville Skyttä
ville.skytta at iki.fi
Thu May 21 08:53:04 UTC 2009
The following commit has been merged in the master branch:
commit cc66ec76f593cc7f15105917b565731c061c68ab
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Thu May 21 11:52:58 2009 +0300
Various postfix completion improvements.
diff --git a/CHANGES b/CHANGES
index af13b70..8d11034 100644
--- a/CHANGES
+++ b/CHANGES
@@ -49,6 +49,7 @@ bash-completion (1.x)
* Fix leaking $prev from cpio, dsniff, freeciv, gkrellm, mkinitrd, and
tcpdump completions.
* Split ant completion to contrib/ant, improve the built in one.
+ * Improve postfix completion.
[ Todd Zullinger ]
* Make yum complete on filenames after install, deplist, update and upgrade
diff --git a/contrib/postfix b/contrib/postfix
index b12bdec..be0d5ab 100644
--- a/contrib/postfix
+++ b/contrib/postfix
@@ -10,25 +10,30 @@ _postfix()
{
local cur prev
+ COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
- if [[ $cur == '-' ]]; then
- COMPREPLY=(-c -D -v)
- return 0
- fi
- if [[ $prev == '-c' ]]; then
- _filedir -d
- return 0
- fi
- if [[ $prev == '-D' ]]; then
- COMPREPLY=( $( compgen -W 'start' -- "`_get_cword`" ) )
+ case $prev in
+ -c)
+ _filedir -d
+ return 0
+ ;;
+ -D)
+ COMPREPLY=( $( compgen -W 'start' -- $cur ) )
+ return 0
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '-c -D -v' -- $cur ) )
return 0
fi
- COMPREPLY=( $( compgen -W 'start stop reload abort flush check' -- \
- "`_get_cword`" ) )
+
+ COMPREPLY=( $( compgen -W 'check start stop abort flush reload status \
+ set-permissions upgrade-configuration' -- $cur ) )
}
-complete -F _postfix postfix
+complete -F _postfix $filenames postfix
# postalias(1) and postmap(1)
#
@@ -36,18 +41,23 @@ _postmap()
{
local cur prev len idx
+ COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
- if [[ $cur == '-' ]]; then
- COMPREPLY=(-N -f -i -n -o -p -r -v -w -c -d -q)
- return 0
- fi
- if [[ $prev == '-c' ]]; then
- _filedir -d
- return 0
- fi
- if [[ $prev == -[dq] ]]; then
+ case $prev in
+ -c)
+ _filedir -d
+ return 0
+ ;;
+ -[dq])
+ return 0
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '-N -f -i -n -o -p -r -v -w -c -d -q'\
+ -- $cur ) )
return 0
fi
@@ -68,7 +78,7 @@ _postmap()
fi
return 0
}
-complete -F _postmap postmap postalias
+complete -F _postmap $filenames postmap postalias
# postcat(1)
#
@@ -76,15 +86,19 @@ _postcat()
{
local cur prev pval len idx qfile
+ COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
- if [[ $cur == '-' ]]; then
- COMPREPLY=(-c -q -v)
- return 0
- fi
- if [[ $prev == '-c' ]]; then
- _filedir -d
+ case $prev in
+ -c)
+ _filedir -d
+ return 0
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '-c -q -v' -- $cur ) )
return 0
fi
@@ -95,7 +109,7 @@ _postcat()
if [[ $qfile == 1 ]]; then
len=${#cur}
idx=0
- for pval in $( mailq | \
+ for pval in $( mailq 2>/dev/null | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
COMPREPLY[$idx]=$pval
@@ -108,7 +122,7 @@ _postcat()
return 0
fi
}
-complete -F _postcat postcat
+complete -F _postcat $filenames postcat
# postconf(1)
#
@@ -116,23 +130,34 @@ _postconf()
{
local cur prev pval len idx eqext
+ COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
- if [[ $cur == '-' ]]; then
- COMPREPLY=(-c -d -e -h -m -l -n -v)
- return 0
- fi
- if [[ $prev == '-c' ]]; then
- _filedir -d
+
+ case $prev in
+ -b|-t)
+ _filedir
+ return 0
+ ;;
+ -c)
+ _filedir -d
+ return 0
+ ;;
+ -e)
+ cur=${cur#[\"\']}
+ eqext='='
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '-A -a -b -c -d -e -h -m -l -n -t -v'\
+ -- $cur ) )
return 0
fi
- if [[ $prev == '-e' ]]; then
- cur=${cur#[\"\']}
- eqext='='
- fi
+
len=${#cur}
idx=0
- for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ); do
+ for pval in $( /usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1 ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
COMPREPLY[$idx]="$pval$eqext"
idx=$(($idx+1))
@@ -140,7 +165,7 @@ _postconf()
done
return 0
}
-complete -F _postconf postconf
+complete -F _postconf $filenames postconf
# postsuper(1)
#
@@ -148,53 +173,59 @@ _postsuper()
{
local cur prev pval len idx
+ COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
- if [[ $cur == '-' ]]; then
- COMPREPLY=(-c -d -h -H -p -r -s -v)
- return 0
- fi
case $prev in
- -[dr])
- len=${#cur}
- idx=0
- for pval in $( echo ALL; mailq | \
- sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY[$idx]=$pval
- idx=$(($idx+1))
- fi
- done
- return 0
- ;;
- -h)
- len=${#cur}
- idx=0
- for pval in $( echo ALL; mailq | \
- sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY[$idx]=$pval
- idx=$(($idx+1))
- fi
- done
- return 0
- ;;
- -H)
- len=${#cur}
- idx=0
- for pval in $( echo ALL; mailq | \
- sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY[$idx]=$pval
- idx=$(($idx+1))
- fi
- done
- return 0
- ;;
+ -c)
+ _filedir -d
+ return 0
+ ;;
+ -[dr])
+ len=${#cur}
+ idx=0
+ for pval in $( echo ALL; mailq 2>/dev/null | \
+ sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
+ if [[ "$cur" == "${pval:0:$len}" ]]; then
+ COMPREPLY[$idx]=$pval
+ idx=$(($idx+1))
+ fi
+ done
+ return 0
+ ;;
+ -h)
+ len=${#cur}
+ idx=0
+ for pval in $( echo ALL; mailq 2>/dev/null | \
+ sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do
+ if [[ "$cur" == "${pval:0:$len}" ]]; then
+ COMPREPLY[$idx]=$pval
+ idx=$(($idx+1))
+ fi
+ done
+ return 0
+ ;;
+ -H)
+ len=${#cur}
+ idx=0
+ for pval in $( echo ALL; mailq 2>/dev/null | \
+ sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
+ if [[ "$cur" == "${pval:0:$len}" ]]; then
+ COMPREPLY[$idx]=$pval
+ idx=$(($idx+1))
+ fi
+ done
+ return 0
+ ;;
esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '-c -d -h -H -p -r -s -v' -- $cur ) )
+ return 0
+ fi
+
COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- $cur ) )
- return 0
}
-complete -F _postsuper postsuper
+complete -F _postsuper $filenames postsuper
}
--
bash-completion
More information about the Bash-completion-commits
mailing list