Skip to content

Conversation

@mdevolde
Copy link

This PR adds bash completion support for several p11* CLI tools.

Features

  • Shared logic in completion/p11-common
  • Specific completions for: p11cat, p11cp, p11kcv, p11ls, p11more, p11mv, p11od, p11setattr
  • Supports PKCS11LIB, PKCS11SLOT, PKCS11PASSWORD as environment fallback
  • Documented usage, environment handling, and limitations

Makefile

  • Adds completion scripts to EXTRA_DIST
  • Installs them to ${datadir}/bash-completion/completions

Limitations

  • Does not support inline env variables (e.g. PKCS11LIB=... p11cat)
  • Zsh is not yet supported, could be addressed in a later contribution

@keldonin keldonin requested a review from Copilot June 25, 2025 14:01
@keldonin keldonin added the enhancement New feature or request label Jun 25, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Bash autocompletion support for various p11* CLI tools by introducing a shared common script and individual completion scripts, and updating the Makefile.am to install them.

  • Introduce completion/p11-common with reusable parsing and completion functions.
  • Add dedicated completion scripts for p11cat, p11cp, p11kcv, p11ls, p11more, p11mv, p11od, and p11setattr.
  • Update Makefile.am to include these scripts in EXTRA_DIST and install them under bash-completion/completions.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
completion/p11-common Shared functions for parsing -l, -s, -p and completing filters
completion/p11cat Autocompletion for p11cat
completion/p11cp Autocompletion for p11cp
completion/p11kcv Autocompletion for p11kcv
completion/p11ls Autocompletion for p11ls
completion/p11more Autocompletion for p11more
completion/p11mv Autocompletion for p11mv
completion/p11od Autocompletion for p11od
completion/p11setattr Autocompletion for p11setattr
Makefile.am Registers and installs completion scripts
Comments suppressed due to low confidence (2)

completion/p11mv:3

  • The comment refers to p11cp but this is the p11mv completion script; update it to p11mv.
# Bash autocompletion for `p11cp`.

completion/p11-common:60

  • Consider adding unit or integration tests for __p11_complete_filters to ensure completion logic works correctly across different argument combinations.
__p11_complete_filters() {

@keldonin keldonin self-assigned this Nov 25, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have support for slot selection. That would require to modify p11slotinfo and add an option to enumerate slots and token, for completion.

Copy link
Contributor

@keldonin keldonin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff.

A few requests:

  • It should support ZSH as well
  • If possible, infer slots as well - that would require to adapt p11slotinfoto yield a list of slots and token, for completion.

@mdevolde mdevolde marked this pull request as draft November 26, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants