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 29924 invoked from network); 23 Aug 2022 03:37:35 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Aug 2022 03:37:35 -0000 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-Type:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=1VjkDnn0Nyfc+Yi0okPoMBsXHeZOGaioNbOpcjFDD2k=; b=PVeaiUINw4gPcwziIgAedHH3lg 1BI2q7Kkb7V5sxkNBRdF/osdv2lUHYpPg3pM3FSFp9hAmHtZ1c320xaimgLICW6OtN9NHU688+rBp t42BO0md4OckBlVXlUEiZDHou18yMnnyYNVjJ1sc5vdTFTM2bjeC73k7d0WmU+lh6v+XqXFOf1Zz4 E/KrMthnY+s6q+r4JZ9LTpsItcBQyscgVw3h909K/VzuOBy4P+kFXMWfGATJADQFve3n9iQo5HNNe PAMLHEIsHOlL4859ZXumCud2k6bIpwirzgJmpJGxt5BIk7PbAKH9IpEWNZjlXivWQ/wcLgd2aEKia MjqwM9pw==; Received: from authenticated user by zero.zsh.org with local id 1oQKjO-000NlX-JS; Tue, 23 Aug 2022 03:37:34 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oQKiU-000N6X-Oz; Tue, 23 Aug 2022 03:36:39 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 252FC27C005A; Mon, 22 Aug 2022 23:36:37 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Mon, 22 Aug 2022 23:36:37 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeikedgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvvefutgesth dtredtreerjeenucfhrhhomhepnfgrfihrvghntggvpgggvghljoiiqhhuvgiiuceolhgr rhhrhihvseiishhhrdhorhhgqeenucggtffrrghtthgvrhhnpeehfffhueejheeugffgfe euudffledvleegffeuhedvveekueegiedugfelueefteenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihvhdomhgvshhmthhprghuth hhphgvrhhsohhnrghlihhthidqudduhedukeejjedtgedqudduledvjeefkeehqdhlrghr rhihvheppeiishhhrdhorhhgsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id DB7EF31A0062; Mon, 22 Aug 2022 23:36:36 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-841-g7899e99a45-fm-20220811.002-g7899e99a Mime-Version: 1.0 Message-Id: <4f73130d-1d7b-46af-ab04-72a04fc89727@www.fastmail.com> In-Reply-To: References: Date: Mon, 22 Aug 2022 23:36:03 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: linuxtechguy@gmail.com Cc: zsh-users@zsh.org Subject: Re: anonymous function question Content-Type: text/plain X-Seq: 27987 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Mon, Aug 22, 2022, at 10:11 PM, Jim wrote: > Is this normal for an anonymous function? This is not just about anonymous functions. You can observe the same behavior with regular functions and other complex commands. % unsetopt INTERACTIVE_COMMENTS % foo() { function> setopt INTERACTIVE_COMMENTS function> #echo test function> } % foo foo:2: command not found: #echo % unsetopt INTERACTIVE_COMMENTS % ( subsh> setopt INTERACTIVE_COMMENTS subsh> #echo test subsh> ) zsh: command not found: #echo % unsetopt INTERACTIVE_COMMENTS % if :; then then> setopt INTERACTIVE_COMMENTS then> #echo test then> fi zsh: command not found: #echo > Why doesn't setting interactive_comments within an anonymous function work? Someone please correct me if I'm mistaken, but I believe that: - Comment removal is performed during parsing. Thus, setting and unsetting INTERACTIVE_COMMENTS changes how parsing is done. - A complex command is parsed *in its entirety* before *any* of its commands are executed. Thus, a command within a complex command cannot affect how the rest of the complex command is parsed. Therefore, a complex command cannot enable or disable comments within itself. It can affect subsequent commands, though: % unsetopt INTERACTIVE_COMMENTS % { cursh> setopt INTERACTIVE_COMMENTS cursh> #echo test cursh> } zsh: command not found: #echo % #echo test % I don't know whether any of this is explicitly described in the documentation. -- vq