zsh-workers
 help / color / mirror / 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

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ https://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git