Skip to content

Bash completions are corrupted by stderr #813

@christian-hackyourshack

Description

When using the Bash CLI completions with a possibly faulty application, the completions are printed over the current line and hence jump around strangely. It seems to be caused, because my app outputs something to stderr while it is recursively called in the _srv_complete() bash-function.

This call of my script is generated here:
https://github.com/c4spar/deno-cliffy/blob/2845b4e9dc91e98f5c61130c66fd4d4bc056775c/command/completions/_bash_completions_generator.ts#L43

And instead of

mapfile -t values < <( srv completions complete "${action}" "${@}" )

it should generate this, redirecting stderr to /dev/null

mapfile -t values < <( srv completions complete "${action}" "${@}" 2>/dev/null )

Then possible output on stderr does not mess up the output and everything is fine. For this oneliner I thought a Pull Request is overweight. If you would still prefer one, I could generate one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions