From mboxrd@z Thu Jan 1 00:00:00 1970
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org
X-Spam-Level:
X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,
T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham
autolearn_force=no version=3.4.4
Received: (qmail 26312 invoked from network); 6 Jun 2022 15:53:47 -0000
Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368)
by inbox.vuxu.org with ESMTPUTF8; 6 Jun 2022 15:53:47 -0000
ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1654530827;
b=n3JMNenw4/xrPnhPonb9P965gAdACnJsnJkcu5WC17oOhlg+AVh0FIgrroITCAZzw8oT9tQjfI
jAUjK/OlRrt1O5NMo0UZ9QogAjMl7VUTDPxjNJ2dUNuGY7ObBoL059lbjBHUlQOs+bH5q2KJN7
tAmaPVqe3vPJdim4JFD162A0AMlgudM8g0ljlqa2L8IoSjHaI7JEqspreV60I7RY7nfRgrAHzO
Iwq+bm6+5q/iRysZwoOkcSBYvL4BTIa3kNkmcSZGOO1XvEeNBfRKWEidTFgBun77azek+fnUBf
L78PaPVzDctL6rBirsKu3hIX7LqSaunghpSbQpHlybJcDw==;
ARC-Authentication-Results: i=1; zsh.org;
iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1654530827;
bh=PAdV3hYx+nPda5jkCb7YfiddwAsmukjmLilqipaB+jE=;
h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help:
List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:
References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature:
DKIM-Signature;
b=Myl80R3QFgHnve4B1L2tQDi84VoltzgCzuNIoH5RgbkQ1Sl4M7it0zjgiqHQztRC8IVEdKGHZg
Zs2/I4KU5LOIbpcs/MEXdp1BD3aJCvuuloHtkD4toDhi9s/VsI5SsbtwZ8+whWKMxjOLeL64Eh
DCUNm6lptVBFwdjGaD8c9IRm631ogSUCjouxSnA1ER4S+Tu9ir5S56SI10AZRaIRtrxf+a43bO
Y+Aspybz0biSp1I1LGyHv33tvwqPyUOeLyV0cdV3cruwSzcwcMXn99YhTS8c6xvJ9I8rUUJ6/k
115vX7gzBXGKOoiu5k7AkEBawhvsXGhjMYdK9wVxqLOdNQ==;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org;
s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:
List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding:
Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From:
Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=wLvs7bs3cU87wm/qHF6EQ2/Z3vqR+sw6xSHLFdqOcw8=; b=ahCL7HWHic20FRgCHGSxspdaK1
bKC1k9uriyAQ4kVM6GObi2Q3lejnrk9ass4HeAwTb4/JmbotrwbTx2ang8eenMGGpO1BTdOm8zF8X
WNmEmDl1dxA1OOjvUotez/mUtmJ5O063C7TaXqIshdn1/jjllf9qDdG63w773tg2vb7+iXrKzHYre
+A5j5VvJC/Edarbc1p/XejbNC6zlzDaPrOrhPNEoFFBBK2uh8MHivJE6G3xkwFkcS5S96uCzWhBBy
8VBhKWdc5H+cNsAv10AP7cQlZ8DhGoZeBLiwlmCC78A3S8MygS1uOhNwTVvRcLnzs0FYZM9GhAxeA
dG2925vg==;
Received: from authenticated user by zero.zsh.org with local
id 1nyF33-000Mkq-Oe;
Mon, 06 Jun 2022 15:53:45 +0000
Authentication-Results: zsh.org;
iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:50134)
by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
id 1nyF2g-000MOy-8h;
Mon, 06 Jun 2022 15:53:27 +0000
Received: from [212.54.57.80] (helo=smtp1.tb.ukmail.iss.as9143.net)
by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1)
(envelope-from
)
id 1nyF2f-0008CA-8q
for zsh-workers@zsh.org; Mon, 06 Jun 2022 17:53:21 +0200
Received: from oxbe13.tb.ukmail.iss.as9143.net ([172.25.160.144])
by smtp1.tb.ukmail.iss.as9143.net with ESMTP
id yF2enOiuaVu5XyF2fn23ij; Mon, 06 Jun 2022 17:53:21 +0200
X-Env-Mailfrom: p.w.stephenson@ntlworld.com
X-Env-Rcptto: zsh-workers@zsh.org
X-SourceIP: 172.25.160.144
X-CNFS-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=629e22f1 cx=a_exe
a=wuFMYA7voKp1dZz7Z+vj5Q==:117 a=wbvTLvLwOfMA:10 a=IkcTkHD0fZMA:10
a=7H6ixmLU1AQA:10 a=NLZqzBF-AAAA:8 a=tJlfC_jBd2W7xBBXTAcA:9 a=QEXdDO2ut3YA:10
a=wW_WBVUImv98JQXhvVPZ:22
X-Authenticated-Sender: p.w.stephenson@ntlworld.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com;
s=meg.feb2017; t=1654530801;
bh=PAdV3hYx+nPda5jkCb7YfiddwAsmukjmLilqipaB+jE=;
h=Date:From:To:In-Reply-To:References:Subject;
b=gNae6QkflNSUyKTW/imU0BC/Y3+9vbOK5B/JNaSL/3/osOsPXPnXtHlEGRFgKD7BO
ZmpNcN4ak3d1XlOayoTaIZ7FKnfQKQS5Del7rsU1RBReBh0K720l61pPsrLMRM9yUI
jGHBGW0rIdf+tf6/xt5bZwhtxj5pjhXIatjwQn2XU5MQt24txV/9izEMEiJsrxy5PK
d1gTfR49bsvwQ82mGTVXf4clcf1rNsttwy7nfzCdKujqi5SHvdlCbt4kLOR2z1xhjG
adJVkmMBTysPbvzYkbmRWey5Gi1VQNTWd2fGYp9KpICZUFfP5J1yvDRCcNkNxYMjWm
N1EISz8Z5B1HA==
Date: Mon, 6 Jun 2022 16:53:20 +0100 (BST)
From: Peter Stephenson
To: Zsh hackers list
Message-ID: <872369693.652069.1654530800982@mail2.virginmedia.com>
In-Reply-To: <136424222.632634.1654505131089@mail2.virginmedia.com>
References:
<1980097513.514587.1653987797049@mail2.virginmedia.com>
<136424222.632634.1654505131089@mail2.virginmedia.com>
Subject: Re: Minor bug(s) with NO_MULTI_FUNC_DEF
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Medium
X-Mailer: Open-Xchange Mailer v7.8.4-Rev72
X-Originating-IP: 147.161.167.85
X-Originating-Client: open-xchange-appsuite
X-CMAE-Envelope: MS4xfOu1rOERgXy0rjY+142J53KnKeWY+lm9tSe1BKLR/DjlKvZa9zkgqWSSZPUN6kZmxFGyXj5LzqOHsobeZZ8AlfCK8kMdrIRhBuUhE06lfP1nAPzzuGHS
K3kDYVnY6B1EVHHlsvqj84Wmv1CccwJiqOSpdRMYiZMDKMtNLUwCZgATSCpqiMJNclJQalwWEHKeYb6NbfiBrIc7hkG8X+Vv7gS/hSsy1rM0RLdKn4tJLric
X-Seq: 50339
Archived-At:
X-Loop: zsh-workers@zsh.org
Errors-To: zsh-workers-owner@zsh.org
Precedence: list
Precedence: bulk
Sender: zsh-workers-request@zsh.org
X-no-archive: yes
List-Id:
List-Help:
List-Subscribe:
List-Unsubscribe:
List-Post:
List-Owner:
List-Archive:
> On 06 June 2022 at 09:45 Peter Stephenson wrote:>
> > To be more precise ... we still don't need to do it differently based
> > on the option, but we might need to retain the "name()" format when
> > it's not affected by the option.
>
> Hmm, this is a real issue. As NO_MULTI_FUNC_DEF is in effect
> for sh emulation, we could in fact tie it to the option. But your
> suggestion has a much lower effect on output of compiled shell code, so that
> could be the way to go.
This looks easy.
pws
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 5e673eb5c..bf73664c9 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1884,6 +1884,11 @@ fn2)var(...)tt(LPAR()RPAR())'; if the option is not set, this causes
a parse error. Definition of multiple functions with the tt(function)
keyword is always allowed. Multiple function definitions are not often
used and can cause obscure errors.
+
+Note that no error is raised if multiple functions are defined as a
+result of a set of names that were originally read as a single word on
+the command line, for example `tt(TRAP{INT,QUIT})'. Although there are
+no plans to change this behaviour at present, it is not guaranteed.
)
pindex(MULTIOS)
pindex(NO_MULTIOS)
diff --git a/Src/text.c b/Src/text.c
index 5cd7685fd..56127c457 100644
--- a/Src/text.c
+++ b/Src/text.c
@@ -578,11 +578,16 @@ gettext2(Estate state)
Wordcode end = p + WC_FUNCDEF_SKIP(code);
int nargs = *state->pc++;
+ if (nargs > 1)
+ taddstr("function ");
taddlist(state, nargs);
if (nargs)
taddstr(" ");
if (tjob) {
- taddstr("() { ... }");
+ if (nargs > 1)
+ taddstr("{ ... }");
+ else
+ taddstr("() { ... }");
state->pc = end;
if (!nargs) {
/*
@@ -594,7 +599,10 @@ gettext2(Estate state)
}
stack = 1;
} else {
- taddstr("() {");
+ if (nargs > 1)
+ taddstr("{");
+ else
+ taddstr("() {");
tindent++;
taddnl(1);
n = tpush(code, 1);
diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst
index af469c527..b8509b25c 100644
--- a/Test/C04funcdef.ztst
+++ b/Test/C04funcdef.ztst
@@ -53,6 +53,26 @@
>b: redirection
>a: redirection
+ define_multiple() {
+ fn1 fn2 fn3() {
+ print This is $0
+ }
+ }
+ which -x2 define_multiple
+ define_multiple
+ fn1
+ fn2
+ fn3
+0: Safe output of multiple function definitions
+>define_multiple () {
+> function fn1 fn2 fn3 {
+> print This is $0
+> }
+>}
+>This is fn1
+>This is fn2
+>This is fn3
+
functions -M m1
m1() { (( $# )) }
print $(( m1() ))