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=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 18124 invoked from network); 8 Jan 2021 18:06:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Jan 2021 18:06:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610129216; b=uvoZG0XW+yX20/pUmsqENasYP2OW8YLKXcV8yFMjZp+0DRQsdWFw9QFEFic6EmeBOdTJRB03RZ 8z2PgnqVtByTPcxY91H4lKvgyOkbwd5L9h0X9iGWNsMY35KhhU8ZsmrUd1yPO64EJMGREGWOQZ /DTVeWLhwPKzemDzssYBvEekpLOWM25w8lS8rspcyX5/bnsiCnRE1lVGuDQ+hgRMxJZ2ZTaNLQ oEHe7dDdv+zqtucwxG0tO5pplTZLxkSyGStkcBZQI9C5GhnP1nOGPVXnoIEG+ckr49FtaCQVYb xwJElRQ7CYdab7cx5914TfCEAJtPI3vw396EQx3D+iZVSw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; 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-20200801; t=1610129216; bh=as6NIpQrjQpHFH1P71Tyxi+m8eumSGT9jlMhRyexxR0=; 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=jH5dFO4B9ByatQUywzTNBV0a+1oG4fQd8oB/pNwBM/wZZFc8A6+UHzpp5h3UTAKDn9ImH2np8P czLMCpOo+Gv8jZ14+8g7RviEiYeLTwf8RZO5TN1zWMuidzNryYyJkPzJ4e7lsVUbyVfIAX/dDq s8598xsBFi8OlFZSO8sGn4L1nxA3tvIap10m+TvPNDlI9692a2m2Lo0ykMNIpc3uhOJmHkY6pO MC7295fTGH8RfaWNnV/1MY70YdNnILx2W+5Tmoz0rHoXxghb7Scmc5waVsZMxGyVlngB8Fc+wB DxcAHb8VF0n/cd/80hQBkcEkdgqeT1Vs+vycEvVXCbWk0Q==; 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: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=okS39iovxW6tiYC0un52ZJFbLw8MsDnXPcjd283PV2o=; b=rWckxRfZc9+7Am/7TUkDC781cc MXRehkQsRj+WU1fvRRXnlOTE/RvXXK89c9+R2w2W9uM8d0i3ooBZNw1ziPr3zvqbtE7FjAzGJA/wj ax0OZqiqf5Z85D5giyk4iAQsYKKdEECbkiuOKee9OJ5QsHcrkxvS9N/1EemC4cUsXjdlgnNiMVz2o RLIgsCGXCsIn9+4/KAUzjKDLCgipvT0s6D8S/k1hEkiFz4zxNasZBXjGrV6dMlb1Lv9pn6sMR9LXJ cDG/6zZaVb0saE3ReKAyBUblIk+9g6sU/SWTVpuF+OxKOk2CK76ju+8AEqiY5sL38KHCqIPSbd3Y2 Pn1r3C7w==; Received: from authenticated user by zero.zsh.org with local id 1kxwA4-000PM8-9m; Fri, 08 Jan 2021 18:06:56 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:43022) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1kxw9U-000OzJ-GS; Fri, 08 Jan 2021 18:06:21 +0000 Received: from [212.54.57.80] (helo=smtp1.tb.ukmail.iss.as9143.net) by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1kxw9U-0001c3-4x for zsh-users@zsh.org; Fri, 08 Jan 2021 19:06:20 +0100 Received: from oxbe20.tb.ukmail.iss.as9143.net ([172.25.160.151]) by smtp1.tb.ukmail.iss.as9143.net with ESMTP id xw9Ukr50qxC0wxw9Uk94lu; Fri, 08 Jan 2021 19:06:20 +0100 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-users@zsh.org X-SourceIP: 172.25.160.151 X-CNFS-Analysis: v=2.4 cv=NpcUz+RJ c=1 sm=1 tr=0 ts=5ff89f1c a=Ip+kZtMD4PYul4iMASbA3A==:117 a=ADWkfsjt5WoA:10 a=IkcTkHD0fZMA:10 a=ac2Zk7JPEtsA:10 a=gir0-LH0AAAA:8 a=QfwH8s3KHpSDOiUBatAA:9 a=QEXdDO2ut3YA:10 a=aLewGyoHDmJ4ULJHWpSz: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=1610129180; bh=as6NIpQrjQpHFH1P71Tyxi+m8eumSGT9jlMhRyexxR0=; h=Date:From:To:In-Reply-To:References:Subject; b=fThI4g5AJvYzGWLdpXW+IXJqr6hvBlp2hEKVYvFfQmYkoh8Yy+j/ozx0Fzd47VIIB 4n/0Yulgbf0zgB1QdZ/65eq0zXbosA8eqjoJs2Yl9BLBfpW2KMp929k6NoQp+UySFw OxBhDo8AwwTf32AzQt6pQSQdlemA2HzCZaCB+rR1Cr569vg9pYB5KdUyJybjqV/gk7 q3etcTEvjpPuKNsolCMeB2r0NQqHiNI2E8HCwG+RTRiHzoqKx4fbU1oHyWN+U9J7Ix nrNByPjG1wk7mQ34Wag7HFUTeb6oqbYdI1bIXhwi7HVSmINMMQOzWJaCKJQJlRVEKJ t5uvIj50maIlw== Date: Fri, 8 Jan 2021 18:06:19 +0000 (GMT) From: Peter Stephenson To: Ray Andrews , zsh-users@zsh.org Message-ID: <600797233.2799876.1610129180019@mail2.virginmedia.com> In-Reply-To: References: <20210107153248.GA25249@tarpaulin.shahaf.local2> <14e91024-d65b-e3a0-f5f6-8f0e55d40e8f@eastlink.ca> <10257162.hLkh6h4pyX@thor> Subject: Re: here document within a switch fails to parse. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 147.161.167.116 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfAA9UlUTCTtZhYS820WUlY3t6XbPPStNZLfRLoU0pUHH84d7yTsdvJdrs34ooVLv9nZdT/RbUQhHi7DypJU6swDkuWluUL0VWtSEf9/Hsej9oH4Pi5y3 CHTEmsmknZQwICtaRSxTrJeSKjovS6CgOy30jkizXUwtWjMmX0Fvk39fw9L9n49suQNlpfcZCyWePgvhDSBYGhOFEeFNV8AmmMG/3TPpXeLYfkUcpLRZfEja HX5TYTv2CCE1tlz8mBqABw== X-Seq: 26349 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: Archived-At: > On 08 January 2021 at 17:13 Ray Andrews wrote: > function test1 () > { > :< $(print something from a function with dollarsign) > print something from a function redirected > /dev/stderr > $(print something from a function both > /dev/stderr)=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 # This is=20 > the only thing that prints. > print something from a function > COMMENT from a function > echo "echo from a function" > EOC > } >=20 > ... not to belabor it, but why in heaven is just that one construction=20 > evaluated? You have what is effectively a double quoted expression. The shell evaluates any substitutions it needs to get the arguments to the command, so it can execute it. It needs to do that so it can end up with a simple set of strings, "command", "command argument 1", and so on. At this point it doesn't care what the command actually is. (In particular, it does NOT think "oh, this is Ray abusing the ":" command, so I'd better not do my usual processing". Nobody has got around to adding that mode to the shell yet.) So how it does it get "command argument 1" from the expression you've passed to it? There are only actually two subsitutions in that expression to be evaluated, the two $(...) expressions; everything else will be passed to the command as is. That includes anything that happens to look like a command --- remember, it's just stuff in a double quoted string at this point. The first $(...) is evaluated. It has no redirection, so that argument to the "print" is substituted into the string. You don't actually see that, it's just part of the command argument now. The second $(...) is evaluated. This time, there's a redirection, so the argument gets sent to stderr, so you see it. There's no output to stdout, so what will actually be substituted into the argument on the command line is the empty string. pws