I'm trying to figure out how a certain line of code from the top of BASH man page tab completion script works:
[[ $OSTYPE == *@(darwin|freebsd|solaris|cygwin|openbsd)* ]] || _userland GNU \
|| return 1
I believe it's a guard; if the BASH special variable $OSTYPE
does not contain one of the strings in the (basic regular?) expression contained within parentheses, or if the userland is GNU then it'll discontinue execution of the script. But, I can't understand how the syntax works or what it means and I don't know what the flow of control is.
You can find the definition of _userland
here:
# Check if we're running on the given userland
# @param $1 userland to check for
_userland()
{
local userland=$( uname -s )
[[ $userland == @(Linux|GNU/*) ]] && userland=GNU
[[ $userland == $1 ]]
}
How does this function work? Does it return a value?
If you could provide references to relevant documentation or articles, that would be helpful. Thank you.