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 16495 invoked from network); 11 May 2022 07:13:40 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 May 2022 07:13:40 -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:To:References:Message-Id:Date:Cc: In-Reply-To:From:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=kOvEfvy076Q/KG4rzAFkTODDuOG6FD6/m//RHcC1mj0=; b=JM71+YC+nilbkrGE9pq7AI0mlR hbZiXPM/vxNnnbnrrbujG1/ehTMrxDqEN7m8jNf2fNQ7uh/JOrs/Pw39Eq1k3ZxLcOK8t3FLjAPOf vyGxrPLnH1k6ZJX9NE7zfUHFJHOGgiBU8ZlXgjEkoxqrrcvL0gMYlgxpuGhKAlo5do52bwXvCN+Cq DWs7L8Vg4jbm0RC9EwRX+UKLw22vUsto20VhUwBVjr0BhE7rKT6DqPH9qqJLBFhQFRB6qpfHeg7k8 84BaXI7qpBPcKUadrD/ebI7sLwAhmP5RNrjpixd32cnCNT63flzbJHJKcklOHkGPQT0Cv+2wYpDp7 rFn7KrMg==; Received: from authenticated user by zero.zsh.org with local id 1nogXT-0006gx-U5; Wed, 11 May 2022 07:13:40 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nogWv-000614-UQ; Wed, 11 May 2022 07:13:06 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 6418527C0054; Wed, 11 May 2022 03:13:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 11 May 2022 03:13:04 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgeeggdduudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurheptgfgggfuhfgjveffkfhfvffosehtqhhmtdhhtdejnecuhfhrohhmpefnrgif rhgvnhgtvggpgggvlhojiihquhgviicuoehlrghrrhihvhesiihshhdrohhrgheqnecugg ftrfgrthhtvghrnhepteegjeehuedtteffhfefffehgfevvdefvdfhfeffgfeuleetffdt geefieeuiefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheplhgrrhhrhihvodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeh udekjeejtdegqdduudelvdejfeekhedqlhgrrhhrhihvpeepiihshhdrohhrghesfhgrsh htmhgrihhlrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 May 2022 03:13:04 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Subject: Re: Commenting and large pipelines From: =?utf-8?Q?Lawrence_Vel=C3=A1zquez?= In-Reply-To: Cc: Zsh Users Date: Wed, 11 May 2022 03:13:03 -0400 Message-Id: <6CA29167-7B1F-4E97-966B-4328868CDD15@zsh.org> References: To: Zach Riggle X-Mailer: iPhone Mail (19E258) X-Seq: 27754 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 May 11, 2022, at 2:37 AM, Zach Riggle wrote: > What I've discovered is that something like this works out pretty well... >=20 > { printf "%s\n" a b foo c bar d fizz XfooX XbuzzX } | > { grep -E 'foo|bar' } | > { > # If the user specified '--no-fizz-buzz', remove those entries > if (( NO_FIZZ_BUZZ )); then > grep -vE 'fizz|buzz' > else > # Pass through everything > cat > fi > } >=20 > I have a few questions about this construct. >=20 > 1. Am I insane for doing this? > 2. In what ways is this a terrible idea? There isn=E2=80=99t anything wrong with (or novel about) using grouped comma= nds as pipeline stages. (However, in your example the braces in the first two stages are unnecessary= and distracting. They make me wonder whether there=E2=80=99s some obscure r= eason you added them.) > 3. Is the use of {} better than ()? I can=E2=80=99t think of a compelling reason to use () other than to force t= he final stage to run in a subshell. (I believe the other stages run in subs= hells regardless.) > Thanks for the attention, just curious what everybody thinks about this ab= use of pipelines and conditional logic. It=E2=80=99s not abuse. It=E2=80=99s entirely valid to use complex commands a= s pipeline stages. Now, whether or not that is more legible or maintainable than the alternativ= es is a different, context-dependent question. --=20 vq Sent from my iPhone=