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 # 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() _userland()
{ {
local uname=$( uname -s ) local userland=$( uname -s )
case $uname in [[ $userland == @(Linux|GNU/*) ]] && userland=GNU
Linux|GNU|GNU/*) echo GNU ;; [[ $userland == $1 ]]
*) echo "$uname" ;;
esac
} }
# This function checks whether we have a given program on the system. # 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 complete -F _gcc gcc g++ c++ g77 gcj gpc
[[ $OSTYPE == *cygwin* || $( _userland ) == GNU ]] \ [[ $OSTYPE == *cygwin* ]] || _userland GNU && _have gcc && \
&& _have gcc && complete -F _gcc cc || : complete -F _gcc cc || :
# Local variables: # Local variables:
# mode: shell-script # mode: shell-script

View File

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

View File

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