I’m not familiar with the semantics of the “-@” in the bash script snippet below, which is from /etc/bash_completion.d/subversion. I’m trying to understand why bash reports “syntax error near unexpected token ‘(‘ on this line, I have two questions:
- What is “-@()” expected to do here?
-
Why might bash be unhappy with this statement?
case $prev in # other cases omitted -@(F|-file|-targets)) _filedir return 0; ;; # other cases omitted esac
The ‘@(…)’ here is part of Bash’s pattern matching syntax. It’s an “or”, it simply matches one of the listed patterns, separated by pipe characters.
The initial dash has simply been factored out of the expression; “-@(a|b|c)” is the same as “@(-a|-b|-c)”, but shorter.
As pointed out by a commenter (thanks!) this requires Bash’s
extglobenabled to work. This is done like so:You can check if you already have it enabled like this: