Make _userland easier to use.

This commit is contained in:
Ville Skyttä 2011-10-16 10:56:44 +03:00
parent 4e5a67cfaf
commit 5afc526850
4 changed files with 10 additions and 11 deletions

View File

@ -92,14 +92,13 @@ complete -b builtin
# start of section containing completion functions called by other functions
# Output what userland we're running on
# Check if we're running on the given userland
# @param $1 userland to check for
_userland()
{
local uname=$( uname -s )
case $uname in
Linux|GNU|GNU/*) echo GNU ;;
*) echo "$uname" ;;
esac
local userland=$( uname -s )
[[ $userland == @(Linux|GNU/*) ]] && userland=GNU
[[ $userland == $1 ]]
}
# This function checks whether we have a given program on the system.

View File

@ -47,8 +47,8 @@ _gcc()
} &&
complete -F _gcc gcc g++ c++ g77 gcj gpc
[[ $OSTYPE == *cygwin* || $( _userland ) == GNU ]] \
&& _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

@ -1,7 +1,7 @@
# man(1) completion
[[ $OSTYPE == *@(darwin|freebsd|solaris|cygwin|openbsd)* || \
$( _userland ) == GNU ]] || return 1
[[ $OSTYPE == *@(darwin|freebsd|solaris|cygwin|openbsd)* ]] || _userland GNU \
|| return 1
_man()
{