From 5b0ca9d43b2ced07ac18cdb6165c63e900b1e665 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 4 Sep 2009 17:07:28 +0200 Subject: [PATCH] Add more debugging to bash completion Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Luca Bigliardi <shammash@google.com> --- autotools/build-bash-completion | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion index b0522b19e..3a986c65a 100755 --- a/autotools/build-bash-completion +++ b/autotools/build-bash-completion @@ -80,6 +80,28 @@ def WritePreamble(sw): sw.Write("# This script is automatically generated at build time.") sw.Write("# Do not modify manually.") + sw.Write("_ganeti_dbglog() {") + sw.IncIndent() + try: + sw.Write("if [[ -n \"$GANETI_COMPL_LOG\" ]]; then") + sw.IncIndent() + try: + sw.Write("{") + sw.IncIndent() + try: + sw.Write("echo ---") + sw.Write("echo \"$@\"") + sw.Write("echo") + finally: + sw.DecIndent() + sw.Write("} >> $GANETI_COMPL_LOG") + finally: + sw.DecIndent() + sw.Write("fi") + finally: + sw.DecIndent() + sw.Write("}") + sw.Write("_ganeti_nodes() {") sw.IncIndent() try: @@ -206,6 +228,8 @@ def WritePreamble(sw): sw.DecIndent() sw.Write("fi") + sw.Write("_ganeti_dbglog optcur=\"'$optcur'\"") + sw.Write("return 1") finally: sw.DecIndent() @@ -214,6 +238,7 @@ def WritePreamble(sw): def WriteCompReply(sw, args, cur="\"$cur\""): sw.Write("""COMPREPLY=( $(compgen %s -- %s) )""", args, cur) + sw.Write("_ganeti_dbglog COMPREPLY=\"${COMPREPLY[@]}\"") sw.Write("return") @@ -452,9 +477,9 @@ def WriteCompletion(sw, scriptname, funcname, ' prev="${COMP_WORDS[COMP_CWORD-1]}"' ' i first_arg_idx choices compgenargs arg_idx optcur') - # Useful for debugging: - #sw.Write("echo cur=\"$cur\" prev=\"$prev\"") - #sw.Write("set | grep ^COMP_") + sw.Write("_ganeti_dbglog cur=\"$cur\" prev=\"$prev\"") + sw.Write("[[ -n \"$GANETI_COMPL_LOG\" ]] &&" + " _ganeti_dbglog \"$(set | grep ^COMP_)\"") sw.Write("COMPREPLY=()") -- GitLab