Bash completions with equals sign and enumerable flag values

后端 未结 2 1241
悲哀的现实
悲哀的现实 2020-12-11 12:28

I\'m trying to construct a bash completion routine that will suggest command lines flags and suitable flag values. For example in the below fstcompose comma

2条回答
  •  余生分开走
    2020-12-11 12:48

    Your first return 0 prevents the second if from being evaluated. Try using a case statement ordered from most-specific to least-specific or at least order your if statements that way.

    Since "=" is included in $COMP_WORDBREAKS, ${prev} is "--compose_filter" without the "=".

    If you remove "=" from $COMP_WORDBREAKS then --compose_filter is still ${cur} rather than ${prev}. Doing so without preserving and restoring its value will break other completions.

    I'm not sure what other problems there may be.

    You can pepper your function with echo statements that are redirected to another terminal to aid in debugging. For example:

    echo "cur: $cur, prev: $prev" > /dev/pts/2
    

提交回复
热议问题