code clean-up
prevent compgen error in _man()
This commit is contained in:
parent
d2cf29b671
commit
9d299d53cd
@ -1,6 +1,6 @@
|
|||||||
# bash_completion - some programmable completion functions for bash 2.05a
|
# bash_completion - some programmable completion functions for bash 2.05a
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.147 2002/02/26 23:21:39 ianmacd Exp $
|
# $Id: bash_completion,v 1.148 2002/02/26 23:59:47 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -112,7 +112,7 @@ have()
|
|||||||
{
|
{
|
||||||
unset -v have
|
unset -v have
|
||||||
type $1 &> /dev/null
|
type $1 &> /dev/null
|
||||||
[ $? = 0 ] && have="yes"
|
[ $? -eq 0 ] && have="yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
# GNU chown(1) completion.
|
# GNU chown(1) completion.
|
||||||
@ -129,7 +129,7 @@ _chown()
|
|||||||
[ "$cur" == -* ] && return 0
|
[ "$cur" == -* ] && return 0
|
||||||
|
|
||||||
# first parameter on line or first since an option?
|
# first parameter on line or first since an option?
|
||||||
if [ $COMP_CWORD = 1 ] || [[ "$prev" == -* ]]; then
|
if [ $COMP_CWORD -eq 1 ] || [[ "$prev" == -* ]]; then
|
||||||
if [[ "$cur" == [a-zA-Z]*.* ]]; then
|
if [[ "$cur" == [a-zA-Z]*.* ]]; then
|
||||||
user=${cur%.*}
|
user=${cur%.*}
|
||||||
group=${cur#*.}
|
group=${cur#*.}
|
||||||
@ -160,7 +160,7 @@ _chgrp()
|
|||||||
[ "$cur" == -* ] && return 0
|
[ "$cur" == -* ] && return 0
|
||||||
|
|
||||||
# first parameter on line or first since an option?
|
# first parameter on line or first since an option?
|
||||||
if [ $COMP_CWORD = 1 ] || [[ "$prev" == -* ]]; then
|
if [ $COMP_CWORD -eq 1 ] || [[ "$prev" == -* ]]; then
|
||||||
_expand || return 0
|
_expand || return 0
|
||||||
COMPREPLY=( $( compgen -g $cur ) )
|
COMPREPLY=( $( compgen -g $cur ) )
|
||||||
fi
|
fi
|
||||||
@ -244,7 +244,7 @@ _insmod()
|
|||||||
modpath=/lib/modules/`uname -r`
|
modpath=/lib/modules/`uname -r`
|
||||||
|
|
||||||
# behave like lsmod for modprobe -r
|
# behave like lsmod for modprobe -r
|
||||||
if [ ${COMP_WORDS[0]} = "modprobe" ] &&
|
if [ $1 = "modprobe" ] &&
|
||||||
[ "${COMP_WORDS[1]}" = "-r" ]; then
|
[ "${COMP_WORDS[1]}" = "-r" ]; then
|
||||||
COMPREPLY=( $( /sbin/lsmod | \
|
COMPREPLY=( $( /sbin/lsmod | \
|
||||||
awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) )
|
awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) )
|
||||||
@ -259,7 +259,7 @@ _insmod()
|
|||||||
|
|
||||||
if [ $COMP_CWORD -gt 1 ]; then
|
if [ $COMP_CWORD -gt 1 ]; then
|
||||||
# do module parameter completion
|
# do module parameter completion
|
||||||
COMPREPLY=( $( /sbin/modinfo -p ${COMP_WORDS[1]} | \
|
COMPREPLY=( $( /sbin/modinfo -p ${COMP_WORDS[1]} 2>/dev/null | \
|
||||||
awk '{if ($1 ~ /^'$cur'/) print $1}' ) )
|
awk '{if ($1 ~ /^'$cur'/) print $1}' ) )
|
||||||
elif [ -r $modpath -a -x $modpath ]; then
|
elif [ -r $modpath -a -x $modpath ]; then
|
||||||
# do module name completion
|
# do module name completion
|
||||||
@ -320,8 +320,8 @@ _man()
|
|||||||
COMPREPLY=( ${COMPREPLY[@]%.*} )
|
COMPREPLY=( ${COMPREPLY[@]%.*} )
|
||||||
|
|
||||||
if [[ "$prev" != [0-9ln] ]]; then
|
if [[ "$prev" != [0-9ln] ]]; then
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d $cur ) \
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) \
|
||||||
$( compgen -f -X '!*.[0-9ln]' $cur ) )
|
$( compgen -f -X '!*.[0-9ln]' -- $cur ) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -391,10 +391,6 @@ _killall()
|
|||||||
}
|
}
|
||||||
[ $OS = Linux ] && complete -F _killall killall
|
[ $OS = Linux ] && complete -F _killall killall
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# GNU find(1) completion. This makes heavy use of ksh style extended
|
# GNU find(1) completion. This makes heavy use of ksh style extended
|
||||||
# globs and contains Linux specific code for completing the parameter
|
# globs and contains Linux specific code for completing the parameter
|
||||||
# to the -fstype option.
|
# to the -fstype option.
|
||||||
@ -454,7 +450,7 @@ _find()
|
|||||||
_expand || return 0
|
_expand || return 0
|
||||||
|
|
||||||
# handle case where first parameter is not a dash option
|
# handle case where first parameter is not a dash option
|
||||||
if [ $COMP_CWORD = 1 -a "$cur" = "$ncur" ]; then
|
if [ $COMP_CWORD -eq 1 -a "$cur" = "$ncur" ]; then
|
||||||
COMPREPLY=( $( compgen -d $cur ) )
|
COMPREPLY=( $( compgen -d $cur ) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -541,7 +537,7 @@ _ifupdown()
|
|||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
if [ -f /etc/debian_version ]; then
|
if [ -f /etc/debian_version ]; then
|
||||||
# Debian system
|
# Debian system
|
||||||
COMPREPLY=( $( sed -ne 's/^iface \([^ ]\+\).*$/\1/p' /etc/network/interfaces ) )
|
COMPREPLY=( $( sed -ne 's/^iface \([^ ]\+\).*$/\1/p' /etc/network/interfaces ) )
|
||||||
@ -566,7 +562,7 @@ _ipsec()
|
|||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look \
|
COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look \
|
||||||
manual pluto ranbits rsasigkey \
|
manual pluto ranbits rsasigkey \
|
||||||
setup showdefaults showhostkey spi \
|
setup showdefaults showhostkey spi \
|
||||||
@ -616,7 +612,7 @@ _cvs()
|
|||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ] || [[ "$prev" == -* ]]; then
|
if [ $COMP_CWORD -eq 1 ] || [[ "$prev" == -* ]]; then
|
||||||
COMPREPLY=( $( compgen -W 'add admin checkout commit diff \
|
COMPREPLY=( $( compgen -W 'add admin checkout commit diff \
|
||||||
export history import log rdiff release remove rtag status \
|
export history import log rdiff release remove rtag status \
|
||||||
tag update' $cur ))
|
tag update' $cur ))
|
||||||
@ -672,7 +668,7 @@ _rpm()
|
|||||||
cur_nodash=${cur#-}
|
cur_nodash=${cur#-}
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
# first parameter on line
|
# first parameter on line
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-b*)
|
-b*)
|
||||||
@ -1024,7 +1020,7 @@ _chkconfig()
|
|||||||
cur_nodash=${cur#--}
|
cur_nodash=${cur#--}
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
COMPREPLY=( $( compgen -W 'list add del level' $cur_nodash ) )
|
COMPREPLY=( $( compgen -W 'list add del level' $cur_nodash ) )
|
||||||
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
|
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
|
||||||
COMPREPLY[i]=--${COMPREPLY[i]}
|
COMPREPLY[i]=--${COMPREPLY[i]}
|
||||||
@ -1130,7 +1126,7 @@ _ssh()
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_known_hosts
|
_known_hosts
|
||||||
[ $COMP_CWORD = 1 ] || \
|
[ $COMP_CWORD -eq 1 ] || \
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( compgen -c $cur ) )
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -c $cur ) )
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -1252,7 +1248,7 @@ _make()
|
|||||||
eval $gcmd ) )
|
eval $gcmd ) )
|
||||||
|
|
||||||
# default to filename completion if all else failed
|
# default to filename completion if all else failed
|
||||||
if [ ${#COMPREPLY[@]} = 0 ]; then
|
if [ ${#COMPREPLY[@]} -eq 0 ]; then
|
||||||
COMPREPLY=( $( compgen -f $cur ) )
|
COMPREPLY=( $( compgen -f $cur ) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1276,7 +1272,7 @@ _service()
|
|||||||
|| sysvdir=/etc/init.d
|
|| sysvdir=/etc/init.d
|
||||||
|
|
||||||
#[[ "$cur" == -* ]] && return 0
|
#[[ "$cur" == -* ]] && return 0
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
COMPREPLY=( $( compgen -W '`echo $sysvdir/!(*.rpmsave|*.rpmorig)`' ) )
|
COMPREPLY=( $( compgen -W '`echo $sysvdir/!(*.rpmsave|*.rpmorig)`' ) )
|
||||||
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$sysvdir/}' $cur ) )
|
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$sysvdir/}' $cur ) )
|
||||||
else
|
else
|
||||||
@ -1436,7 +1432,7 @@ _command()
|
|||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
COMPREPLY=( $( compgen -c $cur ) )
|
COMPREPLY=( $( compgen -c $cur ) )
|
||||||
elif complete -p ${COMP_WORDS[1]} &>/dev/null; then
|
elif complete -p ${COMP_WORDS[1]} &>/dev/null; then
|
||||||
cspec=$( complete -p ${COMP_WORDS[1]} )
|
cspec=$( complete -p ${COMP_WORDS[1]} )
|
||||||
@ -1508,7 +1504,7 @@ _p4()
|
|||||||
uresource uxbinary xbinary xltext xtempobj xtext \
|
uresource uxbinary xbinary xltext xtempobj xtext \
|
||||||
text binary resource"
|
text binary resource"
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
COMPREPLY=( $( compgen -W "$p4commands" $cur ) )
|
COMPREPLY=( $( compgen -W "$p4commands" $cur ) )
|
||||||
elif [ $COMP_CWORD -eq 2 ]; then
|
elif [ $COMP_CWORD -eq 2 ]; then
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
@ -1643,7 +1639,7 @@ _openssl()
|
|||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
COMPREPLY=( $( compgen -W 'asn1parse ca ciphers crl crl2pkcs7 \
|
COMPREPLY=( $( compgen -W 'asn1parse ca ciphers crl crl2pkcs7 \
|
||||||
dgst dh dhparam dsa dsaparam enc errstr gendh gendsa \
|
dgst dh dhparam dsa dsaparam enc errstr gendh gendsa \
|
||||||
genrsa nseq passwd pkcs12 pkcs7 pkcs8 rand req rsa \
|
genrsa nseq passwd pkcs12 pkcs7 pkcs8 rand req rsa \
|
||||||
@ -1704,7 +1700,7 @@ _ncftp()
|
|||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
if [ $COMP_CWORD = 1 ] && [ -f ~/.ncftp/bookmarks ]; then
|
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then
|
||||||
COMPREPLY=( $( compgen -W '`cut --output-delimiter " " \
|
COMPREPLY=( $( compgen -W '`cut --output-delimiter " " \
|
||||||
-s -f1-2 -d, ~/.ncftp/bookmarks`' $cur ) )
|
-s -f1-2 -d, ~/.ncftp/bookmarks`' $cur ) )
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user