Opened 3 years ago

Last modified 3 years ago

#19806 new Bug

django_bash_completion clobbers upstream completion of ‘python’

Reported by: andersk Owned by:
Component: Core (Management commands) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


extras/django_bash_completion now tries to complete python in addition to ./ (#12174), but this results in the upstream completion hook for python being entirely clobbered. For example, the upstream hook completes python -Q, but this is lost when loading django_bash_completion:

$ python -Q <TAB>
new      old      warn     warnall  
$ . extras/django_bash_completion 
$ python -Q <TAB>
AUTHORS           .git/             LICENSE 
CONTRIBUTING.rst  .gitattributes       tests/
django/           .gitignore        README.rst        .tx/
docs/             .hgignore         scripts/
extras/           INSTALL           setup.cfg

That seems like a really unfriendly thing to do, especially on Linux distros where merely installing the Django package pulls in django_bash_completion automatically.

I don’t know of a way to install a completion hook for python without clobbering all of python, so I would propose that the second half of the script (starting at _python_django_completion) should be deleted entirely. Users who want bash completion can type ./ or django-admin instead.

Attachments (2)

ticket19806.diff (2.7 KB) - added by kwadrat 3 years ago. (2.1 KB) - added by andersk 22 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 3 years ago by carljm

  • Component changed from Uncategorized to Core (Management commands)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

Agreed, this is quite unfriendly.

comment:2 Changed 3 years ago by anonymous

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned

comment:3 Changed 3 years ago by kwadrat

  • Owner changed from anonymous to kwadrat

Changed 3 years ago by kwadrat

comment:4 Changed 3 years ago by kwadrat

  • Has patch set
  • Needs tests set
  • Owner kwadrat deleted
  • Status changed from assigned to new

comment:5 Changed 3 years ago by andersk

Copying the upstream completion for python is still unfriendly, because the upstream completion might change, and things will break again if any other package wants to extend python completion. Also, in bash-completion 2, the preferred way to install completions is in /usr/share/bash-completion/completions/command_name where they are loaded dynamically (rather than all at once at startup), which will break this anyway. This really needs some help from bash-completion upstream. Until that happens, I still recommend that the completion for python be removed entirely. For concreteness, I’ll attach that patch below.

Note: See TracTickets for help on using tickets.
Back to Top