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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6225 invoked from network); 21 Oct 2021 14:40:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Oct 2021 14:40:07 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634827207; b=ppXP9D3WBcM8SehMbiXhuJB8PT6aUqbgXbkBY/sWfE84SOBcp0f1MhNGLV2jZ/Vj62Rw/x7cFK MNoxHf+F+JR2CUaOGG4JUgyxJoidzE8rU/h2OViqnfeteo5fQ3RiGGY3QRRwAmB4v27VxJev5Y 3XiYupGUihsaeboRZToyCBXFa8qeLKObCF75eriw2ROY1mB6DyUare03eIwADLFa0g3d2V0iBS 9+vqgRVk1s5Hag2Aate/zyQGWc42xf2htyvyTOv9ussaoTikSDntB1XR7QhZQ5OLu4waD/10jf qDsYD/+BhoK07fgbfZI7RWyDlr0pBPYxB9z7dSElbIlr/w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm1 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=1634827207; bh=kawIndd04KEwfDwgXyLsekfAxdXGNSDjnLSD+ofeq/I=; 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: DKIM-Signature:DKIM-Signature; b=Io91to8ihjaOwEc6lMv33kZNF93NYxXRItae72umyppMsAxIS+5yr++/NXwoc8wmR1D1vCLsCW 0EEfxQQbWKFptqH9JcaPAfQYLp4il2hOsFVFS1KMOTFp1CRRP5LYImeCWJHZrkFLGdUGVdJRRw 67VPPTNZepU5FzHyVu9cS2ovSaMmLgAMOQC5IAiTp8hWRVdQJM+sZBFSo8yq5Te+kmSWFee1Ti 0pR5RIF8PKT/i8MvQ0+1QVq4TPisWpMh1nZpY35xoAKzK++eydeI3S7uyda4uIl73UqGJTKQsS SItRAO7fV3r6+Zcv7u/i4fcI29hgERG9i7A6KSfZIQ4dug==; 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:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=/7Ql4bIlrga+DAdUkNHMo4ZBMCC0dHGWBuuaPFIRTQ4=; b=Gj3utaLJabL4+3kvSON14az0ub 2L7k1lJzEpQylrzRLn/WG5mAyWOE9D2kN+2LLuBfDa4+T+byu+fkB+0kh2fzwuPwdopxyUNgH6qfH PVZNpYtnZslhmW96+Trfs08joCXQ0n92FIxU2p133Sbc/DZiIXpfv6x822RzQ1rRBdcBs0kZpvhNM SkbC6gkVFfbMDYDHOYP0QzefJYSp2FKDO7+tA4REEpQK3g9x+nQYF9Vi9Hi43RLSa//JEmxmJ6MPU coKaDHjC1DvI/7Abfe4hvPLsOjYaydm9R91fLfyetbbnPrhMdabLz33/NuDH7DV9e61OLPpRTB9X2 Nxvu+Upg==; Received: from authenticated user by zero.zsh.org with local id 1mdZEk-000CYZ-Fx; Thu, 21 Oct 2021 14:40:06 +0000 Authentication-Results: zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm1 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 out3-smtp.messagingengine.com ([66.111.4.27]:47797) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mdZDz-000CDA-4s; Thu, 21 Oct 2021 14:39:19 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5449E5C01DC; Thu, 21 Oct 2021 10:39:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 10:39:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm1; bh=/7Ql4bIlrga+DAdUkNHMo4ZBMCC0dHGWBuuaPFIR TQ4=; b=jkuAGxWP96mGxssyykmC23yiQSk0y7j9md/A15Lei+PNXFuIB7Soak6h 9Yq3S+TtgEghB78/S/iQgUqN4bdaeXVAyt8GLniLRd0ifv8GzXvTmlNnLJQW/jNp qdqb8AAud01n2sBx/wfLQH7+g+B0qLM7MaBx4ga7ssQlrcH6+rzQKk+KOX6YcF+6 vD6LvBvjihEx8QIQOjB0ddSdX47DumhWqBpeXHrVe5VRuAywGIcsRmpXWeXfWh98 Va5cly97N9Qt5312rfWtZsS3aKHXPEHH/ZBefxQaW/gN/Wq2IFimprFdLj9rPXrT elGB+XrU/xdoGMsCRFPjCwrp1V805w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=/7Ql4bIlrga+DAdUkNHMo4ZBMCC0dHGWBuuaPFIRT Q4=; b=ehR9XBQVclargEpkkYmBHHSCLoy1Yq68+oZI/rgmX9dR3e0VcTKpxjhnX YQtGmmgzUAI60KdLu9GihYeHmQ0wRnUO4k82y7UnORi3wlhc+Vi5VofydfSqymD2 GwWM6J5Rew4h+xyxb2IYP2xA8hPvMKGh0qiwOODQjErjn0mvJBxu+eRH0LnoHBlM 0ixZPYlePTeVE+htyDJLbkaYW9bBO8dLYT9cxp+acrZ/FOmL9P8Bu4ayTmEemgyG G/97k5wkzDgjptFUrlJleAHKLpuRKkD2PJCOsnUBeFgfZPJ2qeGduQi/ma3r0Mqu +jT4BKthAALlmtgUZI7YB+8G045yA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddviedgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtugfgjggfsehtkedttddtreejnecuhfhrohhmpeffrghn ihgvlhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpefgkefgfeejgfdvvdfguddtleelkedvfeetiedtudfhveev veduhfdvveeffedvueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 10:39:17 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4HZqql6w2Yz4hN; Thu, 21 Oct 2021 14:39:15 +0000 (UTC) Date: Thu, 21 Oct 2021 14:39:15 +0000 From: Daniel Shahaf To: Jett Husher Cc: zsh-workers@zsh.org Subject: Re: What does REDIRF_FROM_HEREDOC flag represent? Message-ID: <20211021143915.GD16034@tarpaulin.shahaf.local2> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 49505 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: Jett Husher wrote on Thu, Oct 21, 2021 at 09:53:42 +0000: > Good day! > > I was peeking at the source code Welcome :) > and found REDIRF_FROM_HEREDOC flag. The comments say that it's for a > here-string that came from a here-document but I'm still not clear how > this looks exactly. A here-string is this thing: item(tt(<<<) var(word))( Perform shell expansion on var(word) and pass the result to standard input. This is known as a em(here-string). Compare the use of var(word) in here-documents above, where var(word) does not undergo shell expansion. ) Example: % nl -ba <<< $'foo\nbar' 1 foo 2 bar % > Is it that every line in heredoc is a here-string? No. > I've tried to read the part in parser.c where this flag is being set, > but couldn't make sense of it since I'm not at all acquainted with C > or the codebase as a whole. I think what happens is this: - After parsing, a here-doc is represented as a here-string with REDIRF_FROM_HEREDOC set - text.c looks for that bit and does the reverse transformation, so stuff like . f() { foo <<< lorem; bar <<'EOF' ipsum EOF } . gets emitted by `which f` using the same type as input redirections as it used when the shell first lexed/parsed it. - exec.c appends a newline to here-strings' data before passing it to commands; see: . % xxd << Would very much appreciate the explanation. > > - Jett >