Hello, function \&abcd() { autoload -X } \&abcd gives: (eval):1: parse error near `&' I wanted to use the symbol as a namespacer for internal functions. -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org
[-- Attachment #1: Type: text/plain, Size: 61 bytes --] This works: function '&f'() { echo f } '&f' Roman.
Yes, but I need the function as an autoload function in a separate file, and I'm loading it with Zplugin, which is constructing a manual autoload -X stub. If anyone has some idea for a good symbol, please share. I'm already using @ for "api calls". Would now need a symbol for "handlers". On Mon, 8 Jul 2019 at 21:40, Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote: > > This works: > > function '&f'() { echo f } > '&f' > > Roman. -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org
Sadly the same applies to a [] prefix, which would be good one for handlers, at it symbolizes an empty space to be filled (by the handler): function \[\]abcd() { autoload -X } noglob []abcd (eval):1: no matches found: []abcd On Mon, 8 Jul 2019 at 21:35, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote: > > Hello, > > function \&abcd() { > autoload -X > } > \&abcd > > gives: > (eval):1: parse error near `&' > > I wanted to use the symbol as a namespacer for internal functions. > -- > Sebastian Gniazdowski > News: https://twitter.com/ZdharmaI > IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin > Blog: http://zdharma.org -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org
On Mon, Jul 8, 2019 at 1:03 PM Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:> > Sadly the same applies to a [] prefix > > On Mon, 8 Jul 2019 at 21:35, Sebastian Gniazdowski > <sgniazdowski@gmail.com> wrote: > > > > I wanted to use the symbol as a namespacer for internal functions. Try this (apologies if gmail line wraps the @@ heading): diff --git a/Src/builtin.c b/Src/builtin.c index 9b9e76c77..7db36c41b 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3029,7 +3029,7 @@ eval_autoload(Shfunc shf, char *name, Options ops, int func) } if (OPT_MINUS(ops,'X')) { char *fargv[3]; - fargv[0] = name; + fargv[0] = quotestring(name, QT_SINGLE_OPTIONAL); fargv[1] = "\"$@\""; fargv[2] = 0; shf->funcdef = mkautofn(shf);
On Tue, 9 Jul 2019 at 00:12, Bart Schaefer <schaefer@brasslantern.com> wrote: > Try this (apologies if gmail line wraps the @@ heading): > > diff --git a/Src/builtin.c b/Src/builtin.c > index 9b9e76c77..7db36c41b 100644 > --- a/Src/builtin.c > +++ b/Src/builtin.c > @@ -3029,7 +3029,7 @@ eval_autoload(Shfunc shf, char *name, Options > ops, int func) > } > if (OPT_MINUS(ops,'X')) { > char *fargv[3]; > - fargv[0] = name; > + fargv[0] = quotestring(name, QT_SINGLE_OPTIONAL); > fargv[1] = "\"$@\""; > fargv[2] = 0; > shf->funcdef = mkautofn(shf); The patch works: echo echo hello > '&abcd' function \&abcd() { autoload -X } \&abcd hello -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org