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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2150 invoked from network); 12 Feb 2021 21:03:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Feb 2021 21:03:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1613163782; b=Ve/Qn9xVQDwZVIzeXM0j4QzeL5wrt/x0mI3MR58PWjQ1tUZNqXaGKHgGp5pfz/PhnaKIPuPzDx AfufQ0ucTqmQwU3O2d4bNefRhNmcj6R5IeicTnX9eSZc9BAGPVn6+e9Te7SdD32ROPbBXIvrL3 iiDlZYS5LpQA/mYqB8YR7I+/qTJ44TjbhrexbycjFEBnvoyY84pCPJGW/a+/OoGnXQxxLgMkkp vIILJFDT6DhncnqPOzjHx5dt5vMXqfbhW8rObtukXD/MFCWQ9KmT7cUNQJjJ0ZX0BsF3F3Z5tV be2chcpXXhvkZt3g5Cwmi1po5YTSe8txYuYP2pzFs4hGyQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1613163782; bh=8KwX+UrF+FVhuBD8TXpthgXH0macguUNmQSZ+mKRPh0=; 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:Cc:To:From:Date:DKIM-Signature; b=jT11bt2Q+XlJHJ4X2qRAqm6oPQbOil1BmwhtHlw//3uqr8tLJINv8AbzNdzeFc3ho7JJkFw6mN dVp7VUyaTQCfReVU3BjS7/3T/QLXnRRl+CCaP5N+mBw4asdBYKl0wlZSu6adcjiEr4X/2/Kmz4 7MOf7I6ImQhjKqX1blZd8fi99UrjIyvAkIu79GuLF6D1tzf3yCNBALQqDwYdXOoJay0mauiVlu jnv6sxlYJyfmiFmG6IXfQxWVSIIOfom2bQjHNMtx1oP3maMRCCumbGdZMW+eWOI37+EbSupdrO QXz+YjH0xwOwm87L39QkgXxx3J9MP/YMCqgM8RbfyWxlCQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; 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:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=V/coPQPSeDgVgDF143XC03LYj+hdyJ0pSpRHwLObRiY=; b=yXOrTAUORip6tIgbXqUnYbjwA1 Wmi+2w/EBE+Xjc1PS3R7P1pKq5/nWesqDiM8sCpNd3JcDZgaG7DZBFTMxRqh1dF84Yh2WVUi4FMAA bapfATsmzkCGsAYfSv5O4g0JBct4mDUS05BIRDJaL+QXa85RCYKzQesMyXn41ZN/2U8NObizHOdev Dmrb8h03U+1Zu/7ISzuTJ80yRPitg+5TWODB5xuaRtDanabVzzxaPqtNoOUX1onxZXBd/kkjeCdz7 KUnhDdhRMhUfJg89LpYaFdJmBx2s06QPMiVsToogS3FbFOZqtBuSI7lnymKWm2cKe7/WnNBAbrzqb A2hrrCAQ==; Received: from authenticated user by zero.zsh.org with local id 1lAfad-0001jd-Hv; Fri, 12 Feb 2021 21:02:59 +0000 Authentication-Results: zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none Received: from relay3-d.mail.gandi.net ([217.70.183.195]:55999) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lAfaJ-0001ZR-4w; Fri, 12 Feb 2021 21:02:39 +0000 X-Originating-IP: 5.71.197.169 Received: from chazelas.org (0547c5a9.skybroadband.com [5.71.197.169]) (Authenticated sender: stephane@chazelas.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id CD22C60004; Fri, 12 Feb 2021 21:02:37 +0000 (UTC) Date: Fri, 12 Feb 2021 21:02:36 +0000 From: Stephane Chazelas To: Lawrence =?utf-8?Q?Vel=C3=A1zquez?= Cc: Bart Schaefer , zsh-workers@zsh.org Subject: Re: Block comments ala Ray Message-ID: <20210212210236.rsmrs65lmtxzoqzc@chazelas.org> Mail-Followup-To: Lawrence =?utf-8?Q?Vel=C3=A1zquez?= , Bart Schaefer , zsh-workers@zsh.org References: <20210212074031.7746vg37xykniem5@chazelas.org> <20210212154547.iy35rp4ijaef22ld@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Seq: 48023 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: Archived-At: 2021-02-12 13:16:28 -0500, Lawrence Velázquez: [...] > This was me, addressing someone with shaky shell fundamentals who > was aliasing the here-document idiom and expecting it to behave > identically to real comments (discarded during lexing, no further > impact on the script). [...] Thanks all for the clarifications. About "discarding during lexing", I did find these btw: $ ksh93 -c $'f() {\n# whatever\necho x\n}; typeset -f f' f() { # whatever echo x } It appears as if they're not discarded(though it looks like it's rather that ksh stores the raw text content (probably only for the "typeset -f" output) in addition to "compiling"/"wordcoding" or however you want to call it (which probably still discards comments)). But see also (as that construct was mentioned in that thread): $ zsh -c 'f() { echo `echo x # comment`; }; typeset -f f; f' f () { echo `echo x # comment` } x $ mksh -c 'f() { echo `echo x # comment`; }; typeset -f f; f' f() { \echo $(echo x # comment) } x $ bash -c 'f() { echo `echo x # comment`; }; typeset -f f; f' f () { echo `echo x # comment` } x as the parsing of the inside of `...` is deferred in all shells except ash-based ones; see $shell -c ':||echo `for`'. A bit like in eval 'echo x # comment'. It's also deferred with the $(...) form in bash (but bash only AFAICT): $ bash -c $'f() { echo $(echo x # comment\n); }; typeset -f f' f () { echo $(echo x # comment ) } That newline is necessary in all shells though there, and that makes the replacing of `...` with $(...) in the typeset -f output by mksh above incorrect: ~$ mksh -c 'f() { echo `echo x # comment`; }; typeset -f f' | mksh mksh: [3]: syntax error: unexpected '}' -- Stephane