From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Vincent Lefevre <vincent@vinc17.net>, zsh-workers@zsh.org
Subject: Re: bad error message "defining function based on alias"
Date: Mon, 16 Jan 2023 17:45:16 +0000 (GMT) [thread overview]
Message-ID: <151772895.2018320.1673891116910@mail.virginmedia.com> (raw)
In-Reply-To: <20230116163829.GA3741240@cventin.lip.ens-lyon.fr>
> On 16/01/2023 16:38 Vincent Lefevre <vincent@vinc17.net> wrote:
> cventin% alias foo=true
> cventin% alias bar=foo
> cventin% bar() { }
> zsh: defining function based on alias `foo'
> zsh: parse error near `()'
diff --git a/Src/input.c b/Src/input.c
index 5a612669b..0da065e51 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -816,6 +816,7 @@ char *input_hasalias(void)
{
int flags = inbufflags;
struct instacks *instackptr = instacktop;
+ char *alias_nam = NULL;
for (;;)
{
@@ -824,9 +825,9 @@ char *input_hasalias(void)
DPUTS(instackptr == instack, "BUG: continuation at bottom of instack");
instackptr--;
if (instackptr->alias)
- return instackptr->alias->node.nam;
+ alias_nam = instackptr->alias->node.nam;
flags = instackptr->flags;
}
- return NULL;
+ return alias_nam;
}
diff --git a/Src/parse.c b/Src/parse.c
index 283225b74..a07a6cc71 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2055,6 +2055,9 @@ par_simple(int *cmplx, int nr)
if (isset(EXECOPT) && hasalias && !isset(ALIASFUNCDEF) && argc &&
hasalias != input_hasalias()) {
zwarn("defining function based on alias `%s'", hasalias);
+ herrflush();
+ if (noerrs != 2)
+ errflag |= ERRFLAG_ERROR;
YYERROR(oecused);
}
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index ca415fa39..1c6969e74 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -123,7 +123,12 @@
eval 'badalias() { print does not work; }')
1:ALIAS_FUNC_DEF off by default.
?(eval):1: defining function based on alias `badalias'
-?(eval):1: parse error near `()'
+
+ (alias firstalias=notacommand
+ alias secondalias=firstalias
+ eval 'secondalias() { print does not work either; }')
+1:ALIAS_FUNC_DEF reports original alias if multiple
+?(eval):1: defining function based on alias `secondalias'
(alias goodalias=isafunc
setopt ALIAS_FUNC_DEF
prev parent reply other threads:[~2023-01-16 17:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 16:38 Vincent Lefevre
2023-01-16 17:45 ` Peter Stephenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=151772895.2018320.1673891116910@mail.virginmedia.com \
--to=p.w.stephenson@ntlworld.com \
--cc=vincent@vinc17.net \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).