Diagnosis: In order to proceed with matching command line words, complgen needs to be able to tell what {{{ echo foo }}} returned but that information gets lost between invocations of the completion functions and therefore it cannot work (it would be too complicated even if it memoized it).
Fix: Allow elements like {{{ ... }}} and <NONTERM>, where <NONTERM> expands to some external command, to only occur at the final position in any alternative (|), fallback (||), repetition (...) or optional ([...]) expression. Also allow the above elements to only occur at the final position in subword expressions. Examples:
For the grammar
cmd ({{{ echo foo }}} | {{{ echo bar }}});
, the following warning gets produced:Warning: Final DFA contains ambiguous transitions; inputs: [Command(u!("echo foo"), 0), Command(u!("echo bar"), 0)]
Diagnosis: In order to proceed with matching command line words, complgen needs to be able to tell what
{{{ echo foo }}}
returned but that information gets lost between invocations of the completion functions and therefore it cannot work (it would be too complicated even if it memoized it).Fix: Allow elements like
{{{ ... }}}
and<NONTERM>
, where<NONTERM>
expands to some external command, to only occur at the final position in any alternative (|
), fallback (||
), repetition (...
) or optional ([...]
) expression. Also allow the above elements to only occur at the final position in subword expressions. Examples:cmd {{{ echo foo }}} {{{ echo bar }}};
cmd ({{{ echo foo }}} | {{{ echo bar }}});
cmd (foo | {{{ echo bar }}});
cmd ({{{ echo foo }}} || {{{ echo bar }}});
cmd (foo || {{{ echo bar }}});
cmd [{{{ echo foo }}}] foo
;cmd {{{ echo foo }}}... foo baz
;