zsh-users / zaw

zsh anything.el-like widget.
BSD 3-Clause "New" or "Revised" License
572 stars 67 forks source link

no_short_loops breaks Zaw compilation #79

Closed psprint closed 8 years ago

psprint commented 8 years ago
% cd ~zaw
% setopt no_short_loops
% rm -f *.zwc
% zcompile zaw.plugin.zsh
zsh: parse error near `source'
zcompile: can't read file: zaw.plugin.zsh

It's about those lines of zaw.plugin.zsh:

# load zaw sources
setopt local_options extended_glob
local src_dir="${cur_dir}/sources" f
if [[ -d "${src_dir}" ]]; then
    for f ("${src_dir}"/^*.zwc) source "${f}"
fi

You really shouldn't use short_loops, they're intended for interactive use (they have drawback – they limit Zsh's parser capability to detect syntax errors). So, to fix, to first lines of zaw.plugin.zsh:

function() {

zmodload zsh/parameter
autoload -U is-at-least

There should be added:

setopt localoptions short_loops

The question is whether zaw want's to change some of Zsh's options. If yes, then better, and overall better, rewrite the loop:

if [[ -d "${src_dir}" ]]; then
    for f ("${src_dir}"/^*.zwc) source "${f}"
fi
-->
if [[ -d "${src_dir}" ]]; then
    for f in "${src_dir}"/^*.zwc; do
       source "${f}"
    done
fi

and forget about any problems with short_loops.

willghatch commented 8 years ago

Thanks for the report.