zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [BUG+PATCH] `zsh -n` shouldn't check for alias func def
Date: Mon, 6 Sep 2021 19:28:10 +0300	[thread overview]
Message-ID: <CAHLkEDv145QULgt56ZDVB9L-jrpNitM4aC2BuqgJHu-5WfnQ5A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

Using `zsh -n` to syntax check gives a false positive for this case,
which is valid syntax:

% zsh -nc 'unalias which-command; which-command() {}'
zsh:1: defining function based on alias `which-command'
zsh:1: parse error near `()'

This patch fixes that.

[-- Attachment #2: 0001-Don-t-check-for-alias-func-defs-when-in-NO_EXEC-mode.txt --]
[-- Type: text/plain, Size: 848 bytes --]

From 963ec42be4d6d980baa468307ee945bc515f0ca3 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlonrichert@users.noreply.github.com>
Date: Mon, 6 Sep 2021 19:24:23 +0300
Subject: [PATCH] Don't check for alias func defs when in NO_EXEC mode

---
 Src/parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Src/parse.c b/Src/parse.c
index be26112a5..10d193ba1 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2052,7 +2052,7 @@ par_simple(int *cmplx, int nr)
 	    /* Error if preceding assignments */
 	    if (assignments || postassigns)
 		YYERROR(oecused);
-	    if (hasalias && !isset(ALIASFUNCDEF) && argc &&
+	    if (isset(EXECOPT) && hasalias && !isset(ALIASFUNCDEF) && argc &&
 		hasalias != input_hasalias()) {
 		zwarn("defining function based on alias `%s'", hasalias);
 		YYERROR(oecused);
-- 
2.30.1 (Apple Git-130)


                 reply	other threads:[~2021-09-06 16:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAHLkEDv145QULgt56ZDVB9L-jrpNitM4aC2BuqgJHu-5WfnQ5A@mail.gmail.com \
    --to=marlon.richert@gmail.com \
    --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).