scripts/dav-bash-completion.bash

changeset 676
fb466ba2edc5
parent 673
8e7e56cfc103
child 684
a4b4257c1a5f
equal deleted inserted replaced
675:a8117c4feaad 676:fb466ba2edc5
1 dav_completion_build_args() {
2 local word
3 for i in "${!COMP_WORDS[@]}"; do
4 word="${COMP_WORDS[$i]}"
5 if [[ "$word" =~ ^\'|^\" ]]; then
6 printf "%s\0" "$word"
7 else
8 echo "$word" | xargs printf "%s"
9 printf "\0"
10 fi
11 done
12 }
13
1 dav_completion() { 14 dav_completion() {
15 local cmd
2 local out 16 local out
3 local cmd_res 17 local cmd_res
4 18
5 out="$(${COMP_WORDS[0]} complete $COMP_CWORD ${COMP_WORDS[@]})" 19 cmd="${COMP_WORDS[0]} complete $COMP_CWORD"
20 out=$(dav_completion_build_args | xargs -0 $cmd)
6 cmd_res=$? 21 cmd_res=$?
7 22
8 if [[ $cmd_res -eq 10 ]]; then 23 if [[ $cmd_res -eq 10 ]]; then
9 compopt -o nospace 24 compopt -o nospace
10 fi 25 fi

mercurial