Thu, 28 Jun 2018 19:22:22 +0200
adds some error detection to completion
dav/main.c | file | annotate | diff | comparison | revisions | |
scripts/dav-bash-completion.bash | file | annotate | diff | comparison | revisions |
--- a/dav/main.c Thu Jun 28 18:55:14 2018 +0200 +++ b/dav/main.c Thu Jun 28 19:22:22 2018 +0200 @@ -2142,7 +2142,7 @@ } DavResource *ls = dav_query(sn, "select - from %s order by name", lspath); - DavResource *elm = ls->children; + DavResource *elm = ls ? ls->children : NULL; while(elm) { sstr_t name = sstr(elm->name); if(sstrprefix(name, filter)) {
--- a/scripts/dav-bash-completion.bash Thu Jun 28 18:55:14 2018 +0200 +++ b/scripts/dav-bash-completion.bash Thu Jun 28 19:22:22 2018 +0200 @@ -4,17 +4,19 @@ local cmd_res davcmd="${COMP_WORDS[0]}" - out=$( $davcmd complete $COMP_CWORD "${COMP_WORDS[@]}" ) - cmd_res=$? + out=$( $davcmd complete $COMP_CWORD "${COMP_WORDS[@]}" ) + cmd_res=$? - if [ $cmd_res == 10 ]; then - compopt -o nospace - fi - if [ $cmd_res == 12 ]; then - compopt -o default - COMPREPLY=() - else + if [ $cmd_res == 10 ]; then + compopt -o nospace + fi + if [ $cmd_res == 12 ]; then + compopt -o default + COMPREPLY=() + else IFS=$'\n' declare -ga 'COMPREPLY=($out)' - fi + fi } +complete -F dav_completion dav +