zsh compinit breaks with KSH_ARRAYS, KSH_GLOB

Bug #1514909 reported by Mikel Ward
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zsh (Ubuntu)
New
Undecided
Unassigned

Bug Description

After upgrading to wily, trying to Tab autocomplete prints a bunch of errors.

It seems that

if [[ -z "$skip_global_compinit" ]]; then
  autoload -U compinit
  compinit
fi

in /etc/zsh/zshrc, and the completion rules it loads from /usr/share/zsh/functions/Completion, is incompatible with KSH_ARRAYS and KSH_GLOB, which previously worked fine in vivid.

Repro:
---
sudo useradd -m zshtest
sudo su - zshtest
cat >.zshrc <<EOF
emulate sh
setopt KSH_ARRAYS
setopt KSH_GLOB
EOF

sudo su - zshtest
cd /<TAB>
mikel-study% cd /
_all_labels:63: bad math expression: operator expected at `funcstack ...'
_description:63: bad math expression: operator expected at `comp_ignor...'
_path_files:63: bad math expression: operator expected at `pfx '
_path_files:63: bad math expression: operator expected at `prepaths '
_path_files:63: bad math expression: operator expected at `ignore '
_path_files:63: bad math expression: operator expected at `ignore'
_main_complete:338: bad math expression: operator expected at `lastdescr'
_main_complete:377: bad math expression: operator expected at `comp_color...'
---

Putting skip_global_compinit=1 in ~/.zshenv works around the problem, as does "unsetopt GLOBAL_RCS".

I imagine my set up is unsupported, but I notice that /usr/share/zsh/functions/Completion/compinit at least makes an attempt to avoid this by doing
---
emulate -L zsh
setopt extendedglob
---

One pattern that seems likely to be problematic is the dynamic definition of functions inside other functions, such as _next_tags creating _all_labels inside its body, which presumably uses the current shell options rather than the ones the completions assume are active.

$ dpkg -S /etc/zsh/zshrc /usr/share/zsh/functions/Completion/Base/_next_tags
zsh-common: /etc/zsh/zshrc
zsh-common: /usr/share/zsh/functions/Completion/Base/_next_tags

$ apt-cache show zsh-common
Package: zsh-common
Priority: optional
Section: shells
Installed-Size: 11882
Maintainer: Ubuntu Developers <email address hidden>
Original-Maintainer: Debian Zsh Maintainers <email address hidden>
Architecture: all
Source: zsh
Version: 5.1.1-1ubuntu1

Revision history for this message
Mikel Ward (mikelward) wrote :

Oops, my repro left out

sudo chsh -s /bin/zsh zshtest

between lines 1 and 2, and

exit

after "EOF" and before the second "sudo su - zshtest".

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.