zsh-workers
 help / color / mirror / code / Atom feed
* [BUG+PATCH] `zsh -n` shouldn't check for alias func def
@ 2021-09-06 16:28 Marlon Richert
  0 siblings, 0 replies; only message in thread
From: Marlon Richert @ 2021-09-06 16:28 UTC (permalink / raw)
  To: Zsh hackers list

[-- 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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-06 16:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 16:28 [BUG+PATCH] `zsh -n` shouldn't check for alias func def Marlon Richert

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).