views:

1628

answers:

1

I was looking through the /etc/bash_completion script found in some Debian packages. I was interested in using the code that looks through a specific directory (/etc/bash_completion.d/ by default) and sources every file in that directory.

Unfortunately, trying to run the script causes errors under the Mac OS X version of bash. The lines in question are:

for i in $BASH_COMPLETION_DIR/*; do
    [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|.rpm*) ]] &&
    [ \( -f $i -o -h $i \) -a -r $i ] && . $i
done

Specifically, my version of bash (3.2.17) chokes on the @() construction. I get that the point of that first test is to make sure we don't source any editor swap files or backups, etc. I'd like to understand exactly what that @() syntax does, and, if possible how to get something similar (and similarly elegant) running on my ancient copy of bash. Can anyone offer insight?

+3  A: 
paxdiablo
Relevant pages of the Bash manual: http://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html and http://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
Adam Rosenfield
Thanks Adam, I was looking for those.
Jim
Excellent. The shopt thing worked great! Thanks for the explanations.
Seth Pellegrino