Skip to content

Use stderr for CLI password prompt #3398

@stephen-dexda

Description

@stephen-dexda

Expected Behavior

foo="$(keepass-cli show <db> -a <attr>)" should display "Insert password to unlock <db>" and store <attr> in $foo.

Current Behavior

Shows no prompt, and stores "Insert password to unlock <db>\n<attr>" in $foo.

With -q, stores <attr> in $foo, but still shows no prompt.

Possible Solution

Send the prompt to stderr so it is printed instead of captured. This is a widespread convention in *nix tools (e.g. "read").

isatty() could also be used if there's some reason not to unconditionally behave this way.

Context

This isn't fixed by #831, as no prompt is shown at all using that option.

When a script is being run interactively, the user needs to be prompted for their password.

A workaround is to manually echo a prompt to stderr beforehand, but there should be a way to get keepassxc-cli to behave similarly to other CLI tools.

Debug Info

KeePassXC - 2.4.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions