* Parse error on autoload -X and a function with & in name
@ 2019-07-08 19:35 Sebastian Gniazdowski
2019-07-08 19:40 ` Roman Perepelitsa
2019-07-08 20:02 ` Sebastian Gniazdowski
0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-08 19:35 UTC (permalink / raw)
To: Zsh hackers list
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Parse error on autoload -X and a function with & in name
2019-07-08 19:35 Parse error on autoload -X and a function with & in name Sebastian Gniazdowski
@ 2019-07-08 19:40 ` Roman Perepelitsa
2019-07-08 19:42 ` Sebastian Gniazdowski
2019-07-08 20:02 ` Sebastian Gniazdowski
1 sibling, 1 reply; 6+ messages in thread
From: Roman Perepelitsa @ 2019-07-08 19:40 UTC (permalink / raw)
To: Sebastian Gniazdowski; +Cc: Zsh hackers list
[-- Attachment #1: Type: text/plain, Size: 61 bytes --]
This works:
function '&f'() { echo f }
'&f'
Roman.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Parse error on autoload -X and a function with & in name
2019-07-08 19:40 ` Roman Perepelitsa
@ 2019-07-08 19:42 ` Sebastian Gniazdowski
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-08 19:42 UTC (permalink / raw)
To: Roman Perepelitsa; +Cc: Zsh hackers list
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Parse error on autoload -X and a function with & in name
2019-07-08 19:35 Parse error on autoload -X and a function with & in name Sebastian Gniazdowski
2019-07-08 19:40 ` Roman Perepelitsa
@ 2019-07-08 20:02 ` Sebastian Gniazdowski
2019-07-08 22:12 ` Bart Schaefer
1 sibling, 1 reply; 6+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-08 20:02 UTC (permalink / raw)
To: Zsh hackers list
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Parse error on autoload -X and a function with & in name
2019-07-08 20:02 ` Sebastian Gniazdowski
@ 2019-07-08 22:12 ` Bart Schaefer
2019-07-08 23:51 ` Sebastian Gniazdowski
0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2019-07-08 22:12 UTC (permalink / raw)
To: Sebastian Gniazdowski; +Cc: Zsh hackers list
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);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Parse error on autoload -X and a function with & in name
2019-07-08 22:12 ` Bart Schaefer
@ 2019-07-08 23:51 ` Sebastian Gniazdowski
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Gniazdowski @ 2019-07-08 23:51 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh hackers list
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-08 23:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 19:35 Parse error on autoload -X and a function with & in name Sebastian Gniazdowski
2019-07-08 19:40 ` Roman Perepelitsa
2019-07-08 19:42 ` Sebastian Gniazdowski
2019-07-08 20:02 ` Sebastian Gniazdowski
2019-07-08 22:12 ` Bart Schaefer
2019-07-08 23:51 ` Sebastian Gniazdowski
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).