summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-10-16 10:56:44 +0300
committerVille Skyttä <ville.skytta@iki.fi>2011-10-16 10:56:44 +0300
commit5afc526850c28ad51ade1ec773ede268157b33bd (patch)
treea53e74aa4f22010784fd492ec6300093aacd3684
parent4e5a67cfaf95dc78d85a896b3dee7cd5c4d5c937 (diff)
downloadbash-completion-5afc526850c28ad51ade1ec773ede268157b33bd.tar.gz
Make _userland easier to use.
-rw-r--r--bash_completion11
-rw-r--r--completions/gcc4
-rw-r--r--completions/ifup2
-rw-r--r--completions/man4
4 files changed, 10 insertions, 11 deletions
diff --git a/bash_completion b/bash_completion
index f01b3a75..4bfa4de8 100644
--- a/bash_completion
+++ b/bash_completion
@@ -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.
diff --git a/completions/gcc b/completions/gcc
index 5fe9c415..0351a6bf 100644
--- a/completions/gcc
+++ b/completions/gcc
@@ -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
diff --git a/completions/ifup b/completions/ifup
index 2bd66ce8..0da6b69f 100644
--- a/completions/ifup
+++ b/completions/ifup
@@ -1,6 +1,6 @@
# Red Hat & Debian GNU/Linux if{up,down} completion
-[[ $( _userland ) == GNU ]] || return 1
+_userland GNU || return 1
_ifupdown()
{
diff --git a/completions/man b/completions/man
index 0575ba3c..e7f82fa8 100644
--- a/completions/man
+++ b/completions/man
@@ -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()
{