Commit b8668c657f35c57c8b38ee66527fabd88d1ef514

Authored by Jay Berkenbilt
1 parent 29631cab

Zsh completion: don't autoload bashcompinit unconditionally

It is the user's responsibility to autoload bashcompinit. If we do it,
we may overwrite a custom complete function. If we don't do it at all,
it won't work out of the box.

This fixes debian bug
1111509, reported by Vincent Lefèvre.
completions/zsh/_qpdf
1 #compdef qpdf 1 #compdef qpdf
  2 +if (( ! $+functions[_bash_complete] && ! $+functions[complete] && ! $+functions[compgen] )); then
  3 + # If the user has not loaded bashcompinit and hasn't otherwise
  4 + # defined the functions it defines, load it. This enables zsh
  5 + # completion to work out of the box for users with no custom
  6 + # configuration. See
  7 + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1111509 for
  8 + # additional discussion.
  9 + autoload -U +X bashcompinit && bashcompinit
  10 +fi
2 eval "$(/usr/bin/qpdf --completion-zsh)" 11 eval "$(/usr/bin/qpdf --completion-zsh)"
  12 +_bash_complete
libqpdf/QPDFArgParser.cc
@@ -190,8 +190,7 @@ QPDFArgParser::completionCommon(bool zsh) @@ -190,8 +190,7 @@ QPDFArgParser::completionCommon(bool zsh)
190 // latter more characters ("$`\) are a problem and it's 190 // latter more characters ("$`\) are a problem and it's
191 // virtually impossible to escape those in a locale-independent 191 // virtually impossible to escape those in a locale-independent
192 // way. 192 // way.
193 - std::cout << "autoload -U +X bashcompinit && bashcompinit &&"  
194 - << "complete -o bashdefault -o default -C '" << progname << "' " << m->whoami 193 + std::cout << "complete -o bashdefault -o default -C '" << progname << "' " << m->whoami
195 << "\n"; 194 << "\n";
196 } else { 195 } else {
197 // we need a function wrapper that discards arguments to avoid 196 // we need a function wrapper that discards arguments to avoid
manual/release-notes.rst
@@ -63,7 +63,8 @@ more detail. @@ -63,7 +63,8 @@ more detail.
63 AcroForm, Dests, Outlines, and PageLabels structures. 63 AcroForm, Dests, Outlines, and PageLabels structures.
64 64
65 - Fix completion scripts and handling to avoid leaking arguments 65 - Fix completion scripts and handling to avoid leaking arguments
66 - into the environment during completion. 66 + into the environment during completion and to correctly handle
  67 + ``bashcompinit`` for zsh users.
67 68
68 - Other enhancements 69 - Other enhancements
69 70