Bash case syntax - value "- @"

I am not familiar with the "- @" semantics in the bash script snippet below, which is located in / etc / bash _completion.d / subversion. I am trying to understand why bash reports "syntax error near unexpected token" ("in this line I have two questions:

  • What does the "- @ ()" expected here mean?
  • Why might bash be unhappy with this statement?

    case $prev in
                    # other cases omitted
        -@(F|-file|-targets))
            _filedir
            return 0;
            ;;
                    # other cases omitted
            esac
    
+5
source share
4 answers

"@ (...)" here is part of the Bash pattern matching syntax . It is "or", it simply matches one of the listed patterns, separated by pipeline symbols.

; "- @(a | b | c)" "@(- a | -b | -c)", .

(!), Bash extglob. :

shopt -s extglob

, :

shopt extglob
+4

, , "@(...)" "extglob". :

shopt -s extglob

script .

+1

"@" - , " ". , , , , .

0

, bash, , :

@(-F|-file|-targets))

... which makes sense, given the other answers here - @ () matches one of the command arguments, and the extra one )is part of the case structure. I just think the dash is in the wrong place.

0
source

All Articles