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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 17334 invoked from network); 2 Jun 2022 10:46:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2022 10:46:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1654166761; b=lGE++q7+6o99V1RwqIgdRAbQtSuDSmAQA7gLGCsN3l8dCfgvVnxQSGphbkCleVi69614i9qYVu 2PJFc6avybYX8+PS7rJRX3M26Q6xubo35uXNNjlVheuTfoA1UMC/Jj9YFlDVVluI/k4tOJYPYe 865kvZuN+WIaWrW5YYEk3feyKXkwufAUR5p8NToCHAhe2i04K2LSLygWcqX/DeJqOzMcV/8LWu cu++9CTvYgwv9L4HIzqPPs0P8eA5ZAz3RzrQgmwxNAaVlCAgnouIH5Ez0j9pfpSAW6OPkr5QW4 E0wAXGsDcp9TxPOiuBHgiyiM6EoriTQKX71jlMdiwrcWNQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout2-smtp.messagingengine.com) smtp.remote-ip=64.147.123.25; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1654166761; bh=TtJ9PTENPpOaGeu5QBEfVTG2opy82N+aSmqXLoapm4w=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=ieD9Qu4U7wC2upuPCJ0IuH4ARUbxa58oYRXS+5ve86sdbvjh76f998dOA/q0Mdz5g/2xNXF1xc X7Mp2jgIwcL3oIiUkXEWIF6yrsMXBsWnm2izKaU7kcNZ76jNe6Z1lMGntdBAoTgWqigfKfcpov gahvAFkU6EvFQxS+wv3Qrrrs5DIKn6mYZCjtBHXVkkY5SyaaUvppJePfALJDfC4F5VdEF0H7u1 q6f2zhJC12DqeIXhr/rRojexkL2TFOECj9Or53EVLHGrm+4NKNVhwrCYkHEkiMO/sJ6WCvHOaS 7a3hfIBn3ZPn+kfQstBlQ2nwu6k7yn88qs7LvQ9HDLLl1g==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=1LDanfkjk7U8F9hAWBd6j5ifq5AWkvV/SOiC7lzifvM=; b=Q5Ch7mnAIC7YDjiSEk2wz4fie1 PUHOf2bFl7nOYEv3rZEUIj0DuB6KFDK+cScPQmyzAzC8P2srgtOLyvNfpmfwcZRWUnITbX+WVTyU4 lU6L/5js0kvADVpe7R/WOtRyRud17xq3XRNh2z00XN1vK+/+hwVSNR3ou50hsn8wsMxa6JqqjZULY pw6W6ozo+SY3PRx5NCLroRvhNUzfAVSbu0niGvES62UwRpfH+H7c9LAsXRd+ZGUTCa1izEZjuf+Xt BBSlfHbHmaMaqLdFStpOZgmav4+LSdKRGTpCZGZL9Le5k4NtscvWq6s8t8tBxOo8IrLVMTMYyRd1P UcU5uAGg==; Received: from authenticated user by zero.zsh.org with local id 1nwiL2-000EoJ-Tn; Thu, 02 Jun 2022 10:46:00 +0000 Authentication-Results: zsh.org; iprev=pass (wout2-smtp.messagingengine.com) smtp.remote-ip=64.147.123.25; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:34275) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nwhyz-000CNd-QE; Thu, 02 Jun 2022 10:23:14 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 1C8A23200970; Thu, 2 Jun 2022 06:23:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 02 Jun 2022 06:23:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm3; t=1654165391; x=1654251791; bh=1LDanfkjk7U8F9hAWBd6j5ifq 5AWkvV/SOiC7lzifvM=; b=Zyv/MXs4q9dnqk9x4WQWmyP+059mjD4wKfIlLq9DS gFJJXtNOQrKsE4+eGd2rga4HNpnr/RCwB/bMVr5Bxrpd2wcN7wyBwppk5/SVtlZa 34DVT/+so0dYwdEtO67PVZJzklDDRG+J7tWtGCrhJGxgnROfwnvLaF1M/IoCDcvm AI6be3FTl8n4cH5STi6ydoVE0/0WhD/rMCOgbDeu1dMiwMCvOwxL8hk2TL7226O7 VwE5udD3fP8D2WKgoyF3b0ZiWoh3tYR3lMJtm/LfKHisNiiI+U2YxjkdXg8+xbd8 6lcnxlFK1uEhRbl8/gjvd0rQJEDfWyKqAYZOR3qUznlyA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1654165391; x=1654251791; bh=1 LDanfkjk7U8F9hAWBd6j5ifq5AWkvV/SOiC7lzifvM=; b=BXw/YOQ6SPAOqLbLA /ImOZCD+dX/auJeE5hsfWhEZe99sl6UAKNgs1wL9PDRMzIOta2xakdXRnmAT4hyb QBZbPOuq8UhSCAgkSM9qXY5I1ebYRxsEyi3oNYcuny0jO0Hk8AITZeUONkuDdh7k rHmXpQ0dLgr8j0HKGjb0I2gtpcglvisnRFX8nPlmrnJr42tfAtvQ6jisAsfDI2uf 4a+KAQw9PxEhD6tjWN3PXmbpfbgb7uyJDoenN/tOEmaOVslibfsNamXBTSFrisKC OZhLvKjNRf8U7bMCeKxLEQ98UQBVjOkixPOWrwj8FTW086HK4yaW4sjFJzcH+Hgx FN1nw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrledvgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtugfgjggfsehtke dttddtredunecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefgleehtdffuefhge euleefffejgedttdelhedvvdeuiefhvefgvdfghfevvdekteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrg hhrghfrdhnrghmvg X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 2 Jun 2022 06:23:11 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4LDMXs61L4z222; Thu, 2 Jun 2022 10:23:09 +0000 (UTC) Date: Thu, 2 Jun 2022 10:23:09 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: Minor bug(s) with NO_MULTI_FUNC_DEF Message-ID: <20220602102309.GF28173@tarpaulin.shahaf.local2> References: <1980097513.514587.1653987797049@mail2.virginmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1980097513.514587.1653987797049@mail2.virginmedia.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 50320 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: Peter Stephenson wrote on Tue, May 31, 2022 at 10:03:17 +0100: > On 30 May 2022 at 21:31 Bart Schaefer wrote: > > As an aside, something like this: > > > > TRAP{HUP,INT,QUIT,TERM} () { print -u2 Got $1 } > > > > bypasses the nomultifuncdef syntax check and successfully defines all > > four functions. > > We could probably document our way out here. It is a single command > line word in origin so the intention must be the obvious one. Devil's advocate: letting this syntax bypass the NO_MULTI_FUNC_DEF check would break the invariant that «foo bar baz qux» and «foo {bar,baz} qux» are always equivalent. So, if we document it, I'd rather it were documented as "This may change in the future" than as a feature. Cheers, Daniel > > diff --git a/Src/hashtable.c b/Src/hashtable.c > index bb165505e..74e838829 100644 > --- a/Src/hashtable.c > +++ b/Src/hashtable.c > @@ -942,10 +942,11 @@ printshfuncnode(HashNode hn, int printflags) > putchar('\n'); > return; > } > - > + > + printf("function "); > quotedzputs(f->node.nam, stdout); > if (f->funcdef || f->node.flags & PM_UNDEFINED) { > - printf(" () {\n"); > + printf(" {\n"); > zoutputtab(stdout); > if (f->node.flags & PM_UNDEFINED) { > printf("%c undefined\n", hashchar); > @@ -983,7 +984,7 @@ printshfuncnode(HashNode hn, int printflags) > } > printf("\n}"); > } else { > - printf(" () { }"); > + printf(" { }"); > } > if (f->redir) { > t = getpermtext(f->redir, NULL, 1); > diff --git a/Src/text.c b/Src/text.c > index 5cd7685fd..89de27ea5 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++; > > - taddlist(state, nargs); > - if (nargs) > + if (nargs) { > + taddstr("function "); > + taddlist(state, nargs); > taddstr(" "); > + } else { > + /* Anonymous function */ > + taddstr("() "); > + } > if (tjob) { > - taddstr("() { ... }"); > + taddstr("{ ... }"); > state->pc = end; > if (!nargs) { > /* > @@ -594,7 +599,7 @@ gettext2(Estate state) > } > stack = 1; > } else { > - taddstr("() {"); > + taddstr("{"); > tindent++; > taddnl(1); > n = tpush(code, 1); > diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst > index 0312fe94e..719a43c3d 100644 > --- a/Test/A01grammar.ztst > +++ b/Test/A01grammar.ztst > @@ -80,7 +80,7 @@ > functions -x3 fn > fn > 0:End of sublist containing ! with no command > ->fn () { > +>function fn { > > : && ! > > : > >} > @@ -95,7 +95,7 @@ > functions -x2 fn > fn > 0:exclamation marks without following commands > ->fn () { > +>function fn { > > ! { > > ! > > } && ! ( > @@ -473,19 +473,19 @@ > fn3() { ( echo foo; ) } > functions fn1 fn2 fn3 > 0:Output of syntactic structures with and without always blocks > ->fn1 () { > +>function fn1 { > > { > > echo foo > > } > >} > ->fn2 () { > +>function fn2 { > > { > > echo foo > > } always { > > echo bar > > } > >} > ->fn3 () { > +>function fn3 { > > ( > > echo foo > > ) > @@ -776,7 +776,7 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci > fn abecedinarian > fn xylophone) > 0: case word handling in sh emulation (SH_GLOB parentheses) > ->fn () { > +>function fn { > > case $1 in > > (one | two | three) print Matched $1 ;; > > (fo* | fi* | si*) print Pattern matched $1 ;; > @@ -846,7 +846,7 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci > which fn > fn > 0:Long case with parsed alternatives turned back into text > ->fn () { > +>function fn { > > typeset ac_file="the else branch" > > case $ac_file in > > (*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj) ;; > diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst > index 17f6dfa29..855c44782 100644 > --- a/Test/A04redirect.ztst > +++ b/Test/A04redirect.ztst > @@ -230,7 +230,7 @@ > eval $'fn-varid() { print {\x18}<<0 }' > { which -x2 fn-varid; fn-varid } | tr $'\x18' '?' > 0:Regression test for off-by-one in varid check > ->fn-varid () { > +>function fn-varid { > > print {?} <<0 > >0 > >} > @@ -575,7 +575,7 @@ > > which redirfn > 0:text output of function with redirections > ->redirfn () { > +>function redirfn { > > local var > > read var > > print I want to tell you about $var > @@ -653,7 +653,7 @@ > fn-two-heres > print $functions[fn-two-heres] > 0:Two here-documents in a line are shown correctly. > ->fn-two-heres () { > +>function fn-two-heres { > > cat < >foo > >x > @@ -679,7 +679,7 @@ > which fn-here-pipe > 0:Combination of HERE-document and |& > >FOO > ->fn-here-pipe () { > +>function fn-here-pipe { > > cat <&1 | cat > >FOO > >HERE > diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst > index d95ee363c..22c84aaec 100644 > --- a/Test/A05execution.ztst > +++ b/Test/A05execution.ztst > @@ -272,7 +272,7 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline > 0: > >No output yet > >Autoloaded ksh style > ->autoload_redir () { > +>function autoload_redir { > > print Autoloaded ksh style > >} > autoload.log > > diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst > index 8b3988151..7ec43adee 100644 > --- a/Test/B02typeset.ztst > +++ b/Test/B02typeset.ztst > @@ -797,10 +797,10 @@ > fn2() { typeset assignfirst=(why not); } > which -x2 fn2 > 0:text output from typeset > ->fn () { > +>function fn { > > typeset foo bar thing=this stuff=(that other) more=woevva > >} > ->fn2 () { > +>function fn2 { > > typeset assignfirst=(why not) > >} > > diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst > index 4366b4142..502365d05 100644 > --- a/Test/C02cond.ztst > +++ b/Test/C02cond.ztst > @@ -355,7 +355,7 @@ F:scenario if you encounter it. > } > which crashme > 0:Regression test for examining code with regular expression match > ->crashme () { > +>function crashme { > > if [[ $1 =~ ^http:* ]] > > then > > url=${1#*=} > @@ -424,7 +424,7 @@ F:scenario if you encounter it. > fn() { [[ 'a' == 'b' || 'b' = 'c' || 'c' != 'd' ]] } > which -x2 fn > 0: = and == appear as input > ->fn () { > +>function fn { > > [[ 'a' == 'b' || 'b' = 'c' || 'c' != 'd' ]] > >} > > diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst > index f120809a7..6483494d3 100644 > --- a/Test/C03traps.ztst > +++ b/Test/C03traps.ztst > @@ -101,13 +101,13 @@ > } > fn1 > 0: Nested TRAPINT, not triggered > ->TRAPINT () { > +>function TRAPINT { > > print INT1 > >} > ->TRAPINT () { > +>function TRAPINT { > > print INT2 > >} > ->TRAPINT () { > +>function TRAPINT { > > print INT1 > >} > > @@ -391,10 +391,10 @@ > fn2 > fn1') > 0:POSIX_TRAPS option > ->TRAPEXIT () { > +>function TRAPEXIT { > > print Exited > >} > ->TRAPEXIT () { > +>function TRAPEXIT { > > print No, really exited > >} > >No, really exited > diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst > index af469c527..2f8ee1fe3 100644 > --- a/Test/C04funcdef.ztst > +++ b/Test/C04funcdef.ztst > @@ -259,7 +259,7 @@ > } > functions fn > 0:Text representation of anonymous function with arguments > ->fn () { > +>function fn { > > () { > > print Anonymous function 1 $* > > } with args > @@ -321,7 +321,7 @@ > barexpansion() { print This is the correct output.; } > funcwithalias > 0:Alias expanded in command substitution does not appear expanded in text > ->funcwithalias () { > +>function funcwithalias { > > echo $(fooalias) > >} > >This is the correct output. > @@ -348,7 +348,7 @@ > ) > 0:autoload containing eval > >oops was successfully autoloaded > ->oops () { > +>function oops { > > print oops was successfully autoloaded > >} > > diff --git a/Test/C05debug.ztst b/Test/C05debug.ztst > index 9a8df1dad..3a428cba0 100644 > --- a/Test/C05debug.ztst > +++ b/Test/C05debug.ztst > @@ -137,7 +137,7 @@ > >6: 'x=y ' > >7: 'print $x' > >y > ->8: 'fn2 () { > +>8: 'function fn2 { > > echo wow > >}' > >9: 'fn2' > diff --git a/Test/E02xtrace.ztst b/Test/E02xtrace.ztst > index 56bc20f1a..59cdfdc5b 100644 > --- a/Test/E02xtrace.ztst > +++ b/Test/E02xtrace.ztst > @@ -164,19 +164,19 @@ > " > done > 0:a function that redefines itself preserves tracing > ->f () { > +>function f { > > # traced > > echo inner > >} > ->foo-bar () { > +>function foo-bar { > > # traced > > echo inner > >} > ->$'\M-c\M-\C-C\M-\C-L' () { > +>function $'\M-c\M-\C-C\M-\C-L' { > > # traced > > echo inner > >} > ->$'ba\C-@z' () { > +>function $'ba\C-@z' { > > # traced > > echo inner > >} > @@ -192,7 +192,7 @@ > functions f > f > 0:define traced function: named function > ->f () { > +>function f { > > # traced > > echo traced named function > >} >