fix potential segfault in para_client
[paraslash.git] / bash_completion
1 _para()
2 {
3 local cur prev sect i manpath tmp
4 COMPREPLY=()
5 cur=${COMP_WORDS[COMP_CWORD]}
6 prev=${COMP_WORDS[COMP_CWORD-1]}
7
8 #_expand || return 0
9
10 case "${COMP_WORDS[1]}" in
11 cs|cs|strdel|strq)
12 COMPREPLY=( $( eval para_client streams | grep "^$cur" \
13 2>/dev/null ) )
14 return 0
15 ;;
16 info|la|us|ca|ls|pic|us)
17 COMPREPLY=( $( eval para_client ls "$cur%" ) )
18 return 0
19 ;;
20 sa)
21 COMPREPLY=( $( eval para_client laa | grep "^$cur" \
22 2>/dev/null ) )
23 return 0
24
25
26
27 esac
28 # default completion if parameter contains /
29 # [[ "$cur" == */* ]] && return 0
30 #echo "cur=$cur"
31 COMPREPLY=( $( eval para_client help | cut -f 1 | sed 1d | grep ^$cur 2>/dev/null ) )
32 # weed out directory path names and paths to man pages
33 COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
34 COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.[0-9ln] ) )
35 return 0
36 }
37 complete -F _para -o default para
38 complete -F _para -o default para_client