Merge branch 'master' of git+ssh://git.debian.org/git/bash-completion/bash-completion

This commit is contained in:
David Paleino 2009-04-14 21:41:15 +02:00
commit a66323a18f
2 changed files with 21 additions and 24 deletions

View File

@ -29,6 +29,9 @@ bash-completion (1.x)
* Rename installed_alternatives() to _installed_alternatives(). * Rename installed_alternatives() to _installed_alternatives().
* Add /etc/pki/tls/openssl.cnf to list of default openssl config files, * Add /etc/pki/tls/openssl.cnf to list of default openssl config files,
search for default ones only if -config is not given. search for default ones only if -config is not given.
* Use POSIX compliant arguments to tail in mkisofs completion.
* Protect various completions from unusual user input by not embedding the
input in external command arguments.
[ Todd Zullinger ] [ Todd Zullinger ]
* Make yum complete on filenames after install, deplist, update and upgrade * Make yum complete on filenames after install, deplist, update and upgrade

View File

@ -375,7 +375,7 @@ _configured_interfaces()
# #
_kernel_versions() _kernel_versions()
{ {
COMPREPLY=( $( command ls /lib/modules | grep "^$cur" ) ) COMPREPLY=( $( compgen -W '$( command ls /lib/modules )' -- $cur ) )
} }
# This function completes on all available network interfaces # This function completes on all available network interfaces
@ -475,14 +475,12 @@ _pnames()
_uids() _uids()
{ {
if type getent &>/dev/null; then if type getent &>/dev/null; then
COMPREPLY=( $( getent passwd | \ COMPREPLY=( $( compgen -W '$( getent passwd | cut -d: -f3 )' -- $cur ) )
awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
elif type perl &>/dev/null; then elif type perl &>/dev/null; then
COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ) ) COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ) )
else else
# make do with /etc/passwd # make do with /etc/passwd
COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\ COMPREPLY=( $( compgen -W '$( cut -d: -f3 /etc/passwd )' -- $cur ) )
/etc/passwd ) )
fi fi
} }
@ -710,8 +708,8 @@ _complete()
return 0 return 0
;; ;;
-@(p|r)) -@(p|r))
COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \ COMPREPLY=( $( complete -p | sed -e 's|.* ||' ) )
grep "^$cur" ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
return 0 return 0
;; ;;
@ -877,12 +875,10 @@ _mount()
fi fi
elif [ -r /etc/vfstab ]; then elif [ -r /etc/vfstab ]; then
# Solaris # Solaris
COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \ COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- $cur ) )
/etc/vfstab | grep "^$cur" ) )
elif [ ! -e /etc/fstab ]; then elif [ ! -e /etc/fstab ]; then
# probably Cygwin # probably Cygwin
COMPREPLY=( $( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \ COMPREPLY=( $( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- $cur ) )
| grep "^$cur" ) )
else else
# probably Linux # probably Linux
if [ $prev = -L ]; then if [ $prev = -L ]; then
@ -890,8 +886,7 @@ _mount()
elif [ $prev = -U ]; then elif [ $prev = -U ]; then
COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- $cur ) ) COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- $cur ) )
else else
COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \ COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab )" -- $cur ) )
/etc/fstab | grep "^$cur" ) )
fi fi
fi fi
@ -1147,8 +1142,7 @@ _find()
-fstype) -fstype)
# this is highly non-portable # this is highly non-portable
[ -e /proc/filesystems ] && [ -e /proc/filesystems ] &&
COMPREPLY=( $( cut -d$'\t' -f 2 /proc/filesystems | \ COMPREPLY=( $( compgen -W "$( cut -d$'\t' -f2 /proc/filesystems )" -- $cur ) )
grep "^$cur" ) )
return 0 return 0
;; ;;
-gid) -gid)
@ -5240,7 +5234,7 @@ _installed_alternatives()
break break
fi fi
done done
COMPREPLY=( $( command ls $admindir | grep "^$cur" ) ) COMPREPLY=( $( compgen -W '$( command ls $admindir )' -- $cur ) )
} }
_update_alternatives() _update_alternatives()
@ -6114,8 +6108,8 @@ _mkisofs()
return 0 return 0
;; ;;
-*-charset) -*-charset)
COMPREPLY=( $( mkisofs -input-charset help 2>&1 | \ COMPREPLY=( $( compgen -W '$( mkisofs -input-charset \
tail +3 | grep "^$cur") ) help 2>&1 | tail -n +3 )' -- $cur ) )
return 0 return 0
;; ;;
-uid) -uid)
@ -6270,10 +6264,10 @@ _ImageMagick()
return 0 return 0
;; ;;
-format) -format)
COMPREPLY=( $( convert -list format | \ COMPREPLY=( $( compgen -W "$( convert -list format | \
awk '/ [r-][w-][+-] / {print $1}' | \ awk '/ [r-][w-][+-] / {print $1}' | \
tr -d '*' | tr [:upper:] [:lower:] | \ tr -d '*' | tr [:upper:] [:lower:] )" \
grep "^$cur" ) ) -- $cur ) )
return 0 return 0
;; ;;
-gravity) -gravity)
@ -6791,7 +6785,7 @@ _cancel()
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
COMPREPLY=( $( lpstat | cut -d' ' -f1 | grep "^$cur" ) ) COMPREPLY=( $( compgen -W "$( lpstat | cut -d' ' -f1 )" -- $cur ) )
} && } &&
complete -F _cancel $filenames cancel complete -F _cancel $filenames cancel
@ -8150,8 +8144,8 @@ _pkg_config()
--list-all --debug --print-errors --silence-errors \ --list-all --debug --print-errors --silence-errors \
--errors-to-stdout -? --help --usage' -- $cur)) --errors-to-stdout -? --help --usage' -- $cur))
else else
COMPREPLY=( $( pkg-config --list-all 2>/dev/null | \ COMPREPLY=( $( compgen -W "$( pkg-config --list-all \
awk '{print $1}' | grep "^$cur" ) ) 2>/dev/null | awk '{print $1}' )" -- $cur ) )
fi fi
} && } &&
complete -F _pkg_config pkg-config complete -F _pkg_config pkg-config