Get rid of remaining $UNAME and $USERLAND uses.

Use $OSTYPE and _userland() instead.
master
Ville Skyttä 2011-10-13 21:26:13 +03:00
parent 5baebf81d3
commit 449c71fa74
5 changed files with 22 additions and 20 deletions

View File

@ -46,17 +46,6 @@ readonly BASH_COMPLETION_COMPAT_DIR
#
_blacklist_glob='@(acroread.sh)'
# Set a couple of useful vars
#
UNAME=$( uname -s )
# strip OS type and version under Cygwin (e.g. CYGWIN_NT-5.1 => Cygwin)
UNAME=${UNAME/CYGWIN_*/Cygwin}
case ${UNAME} in
Linux|GNU|GNU/*) USERLAND=GNU ;;
*) USERLAND=${UNAME} ;;
esac
# Turn on extended globbing and programmable completion
shopt -s extglob progcomp
@ -103,6 +92,16 @@ complete -b builtin
# start of section containing completion functions called by other functions
# Output what userland we're running on
_userland()
{
local uname=$( uname -s )
case $uname in
Linux|GNU|GNU/*) echo GNU ;;
*) echo "$uname" ;;
esac
}
# This function checks whether we have a given program on the system.
#
_have()
@ -960,7 +959,7 @@ _expand()
# This function completes on process IDs.
# AIX and Solaris ps prefers X/Open syntax.
[[ $UNAME == @(SunOS|AIX) ]] &&
[[ $OSTYPE == *@(solaris|aix)* ]] &&
_pids()
{
COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- "$cur" ))
@ -972,7 +971,7 @@ _pids()
# This function completes on process group IDs.
# AIX and SunOS prefer X/Open, all else should be BSD.
[[ $UNAME == @(SunOS|AIX) ]] &&
[[ $OSTYPE == *@(solaris|aix)* ]] &&
_pgids()
{
COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- "$cur" ))
@ -984,7 +983,7 @@ _pgids()
# This function completes on process names.
# AIX and SunOS prefer X/Open, all else should be BSD.
[[ $UNAME == @(SunOS|AIX) ]] &&
[[ $OSTYPE == *@(solaris|aix)* ]] &&
_pnames()
{
COMPREPLY=( $( compgen -X '<defunct>' -W '$( command ps -efo comm | \
@ -1866,7 +1865,7 @@ unset i
[[ ${BASH_SOURCE[0]} != ~/.bash_completion && -r ~/.bash_completion ]] \
&& . ~/.bash_completion
unset -f have
unset UNAME USERLAND have
unset have
set $BASH_COMPLETION_ORIGINAL_V_VALUE
unset BASH_COMPLETION_ORIGINAL_V_VALUE

View File

@ -47,7 +47,8 @@ _gcc()
} &&
complete -F _gcc gcc g++ c++ g77 gcj gpc
[[ $USERLAND == GNU || $UNAME == Cygwin ]] && _have gcc && complete -F _gcc cc
[[ $OSTYPE == *cygwin* || $( _userland ) == GNU ]] \
&& _have gcc && complete -F _gcc cc
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,6 @@
# Red Hat & Debian GNU/Linux if{up,down} completion
#
[ $USERLAND = GNU ] || return 1
[[ $( _userland ) == GNU ]] || return 1
_ifupdown()
{

View File

@ -14,7 +14,7 @@ _killall()
return 0
} &&
complete -F _killall pkill
[[ $UNAME == @(Linux|FreeBSD|Darwin) ]] && complete -F _killall killall
[[ $OSTYPE == *@(linux|freebsd|darwin)* ]] && complete -F _killall killall
# Local variables:
# mode: shell-script

View File

@ -1,6 +1,8 @@
# man(1) completion
[[ $USERLAND == GNU || $UNAME == @(Darwin|FreeBSD|SunOS|Cygwin|OpenBSD) ]] &&
[[ $OSTYPE == *@(darwin|freebsd|solaris|cygwin|openbsd)* || \
$( _userland ) == GNU ]] || return 1
_man()
{
local cur prev words cword split