# bash completion for brctl -*- shell-script -*- proc _brctl { var cur = '', prev = '', words = '', cword = '' _init_completion || return var command = $(words[1]) matchstr $cword { 1 { global COMPREPLY := '( '$( compgen -W "addbr delbr addif delif setageing setbridgeprio setfd sethello setmaxage setpathcost setportprio show showmacs showstp stp" -- "$cur" ) ) } 2 { matchstr $command { show { } * { global COMPREPLY := '( '$( compgen -W "$($1 show | \ awk 'NR>1 {print $1}' )" -- "$cur" ) ) } } } 3 { matchstr $command { addif|delif { _configured_interfaces } stp { global COMPREPLY := '( '$( compgen -W 'on off' -- "$cur" ) ) } } } } } && complete -F _brctl -o default brctl # ex: ts=4 sw=4 et filetype=sh (CommandList children: [ (AndOr children: [ (FuncDef name: _brctl body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs:(LhsName name:cur) op:Equal spids:[13]) (assign_pair lhs:(LhsName name:prev) op:Equal spids:[15]) (assign_pair lhs:(LhsName name:words) op:Equal spids:[17]) (assign_pair lhs:(LhsName name:cword) op:Equal spids:[19]) ] spids: [11] ) (AndOr children: [(C {(_init_completion)}) (ControlFlow token:)] op_id: Op_DPipe ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:command) op: Equal rhs: { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 1)})) spids: [33 38] ) } spids: [32] ) ] spids: [30] ) (Case to_match: {($ VSub_Name "$cword")} arms: [ (case_arm pat_list: [{(1)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(compgen)} {(-W)} { (DQ ("addbr delbr addif delif setageing\n") ( " setbridgeprio setfd sethello setmaxage setpathcost setportprio\n" ) (" show showmacs showstp stp") ) } {(--)} {(DQ ($ VSub_Name "$cur"))} ) ] ) left_token: spids: [56 74] ) } ] ) } spids: [53] ) ] spids: [53] ) ] spids: [49 50 79 -1] ) (case_arm pat_list: [{(2)}] action: [ (Case to_match: {($ VSub_Name "$command")} arms: [ (case_arm pat_list: [{(show)}] spids: [93 94 97 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(compgen)} {(-W)} { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {($ VSub_Number "$1")} {(show)} ) (C {(awk)} { (SQ <"NR>1 {print $1}">) } ) ] negated: False ) ] ) left_token: spids: [114 129] ) ) } {(--)} {(DQ ($ VSub_Name "$cur"))} ) ] ) left_token: spids: [107 138] ) } ] ) } spids: [104] ) ] spids: [104] ) ] spids: [100 101 -1 143] ) ] spids: [86 90 143] ) ] spids: [82 83 146 -1] ) (case_arm pat_list: [{(3)}] action: [ (Case to_match: {($ VSub_Name "$command")} arms: [ (case_arm pat_list: [{(addif)} {(delif)}] action: [(C {(_configured_interfaces)})] spids: [160 163 169 -1] ) (case_arm pat_list: [{(stp)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:COMPREPLY) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (C {(compgen)} {(-W)} {(SQ <"on off">)} {(--)} {(DQ ($ VSub_Name "$cur"))} ) ] ) left_token: spids: [179 195] ) } ] ) } spids: [176] ) ] spids: [176] ) ] spids: [172 173 200 -1] ) ] spids: [153 157 203] ) ] spids: [149 150 206 -1] ) ] spids: [42 46 209] ) ] spids: [8] ) spids: [4 7] ) (C {(complete)} {(-F)} {(_brctl)} {(-o)} {(default)} {(brctl)}) ] op_id: Op_DAmp ) ] )