Skip to content

Completions Spamming History #858

@mredig

Description

@mredig

(disclaimer: real user experiencing issue - ai helped investigate and write up report - user validated for accuracy)

The generated bash completion script pollutes the user's shell history with dozens of set +o/set -o commands every time tab completion is triggered. This makes the bash history nearly unusable.

ArgumentParser version: 1.7.0 (current release) and main branch
Swift version: Swift version swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)

Checklist

  • If possible, I've reproduced the issue using the main branch of this package
    • (it's late and it's hard to validate for 100% certain that I didn't have a dirty env and reuse an old completion file, but i DID try)
  • I've searched for existing GitHub issues

Steps to Reproduce

Use the FingerString CLI tool as a live example (small codebase, easy to parse):

  1. using bash as your shell...
  2. Install FingerString:
brew tap mredig/pizza-mcp-tools
brew install fingerstring

Or build from source:

git clone https://github.com/mredig/FingerString.git
cd FingerString
swift build
  1. Generate and source the bash completion script:
fingerstring --generate-completion-script bash > fingerstring-completion.bash
source fingerstring-completion.bash
  1. Trigger tab completion 3-4 times:
fingerstring list-<TAB>
fingerstring task-<TAB>
fingerstring <TAB>
  1. Check bash history:
history | tail -100

Reference code: The tool uses custom completions in several commands. All tested completions cause this behavior. See examples:

Expected behavior

Tab completion should work without polluting the user's bash history. Ideally, the history should only contain actual commands the user executed, not internal shell state inspection commands from the completion script.

Actual behavior

Every tab completion trigger adds approximately 20 set +o/set -o commands to bash history:

1001  set +o ignoreeof
1002  set -o interactive-comments
1003  set +o keyword
1004  set -o monitor
1005  set +o noclobber
1006  set +o noexec
1007  set +o noglob
1008  set +o nolog
1009  set +o notify
1010  set +o nounset
1011  set +o onecmd
1012  set +o physical
1013  set +o pipefail
1014  set +o posix
1015  set +o privileged
1016  set +o verbose
1017  set +o vi
1018  set +o xtrace
1019  fingerstring list-all
1020  set +o ignoreeof
1021  set -o interactive-comments
...

This repeats every time tab completion is used, making bash history nearly unusable with dozens or hundreds of these commands accumulating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions