From 4c3657a18009abd762a2bce31c76a6ef5c633671 Mon Sep 17 00:00:00 2001 From: Nick Patavalis Date: Fri, 9 Feb 2018 11:28:01 +0200 Subject: [PATCH] Handle arg values given with = --- bash_completion/picocom | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bash_completion/picocom b/bash_completion/picocom index b143231..dc06529 100644 --- a/bash_completion/picocom +++ b/bash_completion/picocom @@ -298,21 +298,19 @@ _picocom() echo "------------" > $DEBUG echo COMP_LINE "$COMP_LINE" > $DEBUG echo COMP_POINT $COMP_POINT > $DEBUG - echo COMP_CWORD $COMP_CWORD > $DEBUG local wrd - for wrd in "${COMP_WORDS[@]}"; do + for wrd in "${words[@]}"; do echo -n "$wrd | " > $DEBUG done echo > $DEBUG echo "$prev | $cur | " > $DEBUG - # Try to handle option values given with "=" - if [[ $cur == "=" ]]; then + # Handle option values given with "=" or "==" + if [[ $cur =~ "="+ ]]; then _picocom_is_opt "$prev" && cur= fi - if [[ $prev == "=" && $COMP_CWORD -gt 1 ]]; then - prev1="${COMP_WORDS[COMP_CWORD-2]}" - _picocom_is_opt "$prev1" && prev="$prev1" + if [[ $prev =~ "="+ ]]; then + _picocom_is_opt "${words[-3]}" && prev="${words[-3]}" fi case "$prev" in @@ -380,7 +378,7 @@ _picocom() ;; esac - if [[ ${cur} = -* ]] ; then + if [[ ${cur} == -* ]] ; then COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") ) # This only works for bash 4.4 and newer compopt -o nosort > /dev/null 2>&1