What is @(...|...|...) syntax in bash?

Viewed 2029

To focus on the @() syntax mentionned in this question :

[[ $OSTYPE == *@(darwin|freebsd|solaris|cygwin|openbsd)* ]]

Where does this syntax come from ? Why is it used in this case ? And what is the difference with :

[[ $OSTYPE =~ (darwin|freebsd|solaris|cygwin|openbsd) ]]

or

[[ $OSTYPE == *(darwin|freebsd|solaris|cygwin|openbsd) ]]

that all seems equivalents.

Is this syntax used in place of the =~ operator for better portability with regex ?

Thanks for your clarifications

2 Answers
Related