Subject: Re: Quoting problems
From: Peter Stephenson <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Tue, 16 Feb 2016 09:33:39 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Tue, 16 Feb 2016 08:53:05 +0100
Sebastian Gniazdowski <[email-masked]> wrote:
> Hello,
> # source test_script > a
> # source ./a
> ./a:156: unmatched "
> ./a:157: invalid function definition
> 
> 
> It's about following line:
> [[ $#exp -eq 1 && "${exp[1]//\}" = "${word//\}"(|\(N\)) ]]
> 
> The first and second backslash aren't quoted and cause the two '{' to
> be unbound.

Looking at your code, I think you'll find this is because you're using
echo without the option not to expand bacslashes.  Try "echo -E" or
"print -r".  (I'd recommend "print" if this is zsh-specific as echo
is mostly there for backward compatibility, although there's no reason
it shouldn't work here.)

pws