When you have strange things in your ~/.basrc (like grep --color=always) then beaker autocompletion can produce wrong output. example: burlak@borg /e/bash_completion.d $ bkr -h ^[[m^[[Kpolicy-revoke^[[01;31m^[[K --help ^[[m^[[Kremove-account^[[01;31m^[[K ^[[m^[[Kdistros-edit-version^[[01;31m^[[K ^[[m^[[Ksystem-delete^[[01;31m^[[K ^[[m^[[Kdistros-list^[[01;31m^[[K ^[[m^[[Ksystem-details^[[01;31m^[[K ^[[m^[[Kdistros-tag^[[01;31m^[[K
This patch will ensure that bkr autocompletion will always use original `grep`.
Signed-off-by: Andrej Manduch amanduch@gmail.com --- Client/bash-completion/bkr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Client/bash-completion/bkr b/Client/bash-completion/bkr index 76d6b9e..f64e1c0 100644 --- a/Client/bash-completion/bkr +++ b/Client/bash-completion/bkr @@ -7,9 +7,10 @@ # Function expands options from main option (like workflow-tcms) _bkr_complete() { + local GREP=`which grep --skip-alias` local component=$( echo $COMP_LINE | cut -d' ' -f2 ) if [ $component != "" ] ; then - local opts=$(echo $( bkr $component --help 2>/dev/null | grep -o -- '--[^ =]*' | sort | uniq ) --help ) + local opts=$(echo $( bkr $component --help 2>/dev/null | $GREP -o -- '--[^ =]*' | sort | uniq ) --help )
[[ $COMP_LINE == bkr\ $component* ]] && \ printf %s "$opts" @@ -20,6 +21,7 @@ _bkr_complete() _bkr() { COMPREPLY=() + local GREP=`which grep --skip-alias` local bkr=$1 local cur prev local -a words @@ -30,7 +32,7 @@ _bkr() fi
# Commands offered as completions for bkr - local cmds=( $( bkr --help 2>/dev/null | grep " " | cut -d' ' -f3 | sed '1d' | cut -d'=' -f1 ) -h --help ) + local cmds=( $( bkr --help 2>/dev/null | $GREP " " | cut -d' ' -f3 | sed '1d' | cut -d'=' -f1 ) -h --help )
local i c cmd for (( i=1; i < ${#words[@]}-1; i++ )) ; do
Thanks for the patch! Merged, will be in the next release.
Excerpts from Andrej Manduch's message of 2015-02-27 06:38 +10:00:
When you have strange things in your ~/.basrc (like grep --color=always) then beaker autocompletion can produce wrong output. [...]
beaker-devel@lists.fedorahosted.org