3 local WORD OPTS OPTARG OPTEND SOPT LOPT TARG
4 local SOPTS=(g s f n i o e c q v h V)
5 local LOPTS=(get set file fd stdin stdout stderr check quiet verbose help version)
6 local AOPTS=(0 1 1 1 0 0 0 0 0 0 0 0) # takes argument
7 local TOPTS=(1 0 1 1 1 1 1 0 0 0 0 0) # specifies target
8 local XOPTS=(0 0 0 0 0 0 0 0 0 0 1 1) # exits immediately
9 local MOPTS=(0 0 1 1 0 0 0 0 0 0 0 0) # repeatable
10 local NOPTS=(0 0 0 0 0 0 0 0 0 0 0 0) # number of repeats
11 local IDXG=0 IDXS=1 # index of --get and --set
13 for ((i=1; i<COMP_CWORD; i++)); do
16 if [[ ${NOPTS[$IDXG]} -eq 0 ]]; then
19 _command_offset $((i+1))
27 for ((j=0; j<${#NOPTS[@]}; j++)); do
39 if [[ ${XOPTS[$j]} -ne 0 ]]; then
46 [[ ${TOPTS[$j]} -ne 0 ]] && TARG=y
47 [[ $OPTEND != n ]] && ((i+=AOPTS[j]))
48 [[ $OPTEND == l ]] && break
65 COMPREPLY=( $(compgen -f -- "$2") )
68 COMPREPLY=( $(compgen -W "0 1 2" -- "$2") )
72 if [[ ! $WORD =~ ^[0-9]+[a-zA-Z]*$ ]]; then
77 while [[ $WORD =~ [a-zA-Z]$ ]]; do WORD=${WORD:0:-1}; done
80 COMPREPLY=( $(compgen -W "$WORD $WORD{K,M,G}{B,iB}" -- "$2") )
84 for ((j=0; j<${#NOPTS[@]}; j++)); do
85 [[ $j -eq $IDXG && ${NOPTS[$IDXS]} -ne 0 ]] && continue
86 [[ $j -eq $IDXS && ${NOPTS[$IDXG]} -ne 0 ]] && continue
87 [[ $COMP_CWORD -ne 1 && ${XOPTS[$j]} -ne 0 ]] && continue
88 [[ ${NOPTS[$j]} -gt 0 && ${MOPTS[$j]} -eq 0 ]] && continue
90 [[ $2 != --* && $2 == -* ]] && OPTS+=" -${SOPTS[$j]}"
91 OPTS+=" --${LOPTS[$j]}"
94 if [[ ! $TARG || ${NOPTS[$IDXG]} -ne 0 ]]; then
95 COMPREPLY=( $(compgen -W "$OPTS" -- "$2") )
98 COMPREPLY=( $(compgen -c -W "$OPTS --" -- "$2") )
102 complete -F _pipesz_module pipesz