Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Surprising effect of fun() { local FPATH=...; autoload -X }, and a bug



On 27 September 2016 at 09:05, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Sebastian Gniazdowski wrote on Tue, Sep 27, 2016 at 00:07:37 +0200:
>>             eval "function $func {
>>                 local FPATH="$PLUGIN_DIR":"${FPATH}"
>>                 builtin autoload -X ${opts[*]}
>>             }"
>
> The " signs in the first line of the function body need to be escaped.
>
> The parameter expansions $foo need to be escaped, some as \$foo and
> others as ${(q)foo}.

As we discussed on IRC, the final version is like following – quoting
in 4 new places:
                eval "function ${(q)func} {
                    local FPATH=${(qqq)PLUGIN_DIR}:${(qqq)FPATH}
                    builtin autoload -X ${(q-)opts[@]}
                }"

Best regards,
Sebastian Gniazdowski



Messages sorted by: Reverse Date, Date, Thread, Author