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=-6.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15060 invoked from network); 15 Oct 2022 02:58:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 15 Oct 2022 02:58:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1665802716; b=RwOd1a3o3m+Bpe8u4QaEVjyr3V6fzPphDYnSM49SiR6QbtseepcSPN/Y6YQ2GwXSfwQixGNE68 yODN4qki8bZjX77zFw1W20hBzKLh3K55ci9TJvRocf3urhxvzR3x7j+qlVSmp2ptS2ul0q6JGz JgKiMnZQJA8Eoiv3gtk0hH+nlVgIbTriqM+C+wz+iEH/AxFX555vPdvQYuXnn/Q4C48KwBVGTy ZfAXVltKO08gAldbNtosNbGcY6+dQ6XkJKZEQN6QK6SJBymMi1Et4Z9XKz8WiRD9VbzbiqbdYV pvUKMYMSA8NDl6EOBFT7inZcFmNAGJyYXYU40b1Bq8YUyQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1665802716; bh=NVNAm/AcIAsYbydH8hAbPtHha7qcrhB00O1Yk/6N8m4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=eBIx1c0MWoJqpaw/b1qcbSys7bSGh0oRjSwb6r9+m+27Xujo5EIA0aFfN9mn0Zj1dF2XUZNPn5 I549VvA7hbSz4P3ulQSrgS82rRdLeNJC5q2KfYhfo6m+5dSm6K8EML9o83R13zVdpOHGHZdZfW E4xZOJhpDV7xcWSiABOc/lLO/3fHDoxXeFASBqGgFqa+GYvnwo3C5A52YIFpeEqxe27jR+kdfq uC1sOMV2bteuBew4kEuuAwU5/wULnSHclvLGyozpaHp7x2oUqmEKoCI1wwFMWDunnW677k2R3e NwEY6Mi3AK7AkL2633o9WpUAUMT7u3r4+m2Y5cGuDMzqEQ==; 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-transfer-encoding: Content-type:In-reply-to:From:References:To:Subject:MIME-version:Date: Message-id:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=N1v0a5n6fxnXwYNjcmCFH2Ne2A5mp9DdWbcD6L3qdL0=; b=kuaVmM+Qxn4r8OscDNHmZ0h4WQ VRafJSxBkpiOI+tbrv0/6hDA+nYmrppHr3fUPIQi28uSHr1WKZ7jbUNvOJ4MHqned5XjIOUXGP5Ty RwsQUQh9S2qAD5+yzyL9zHpo/HQg3m7mItFsEjh1mw8usQtIHYLFbxci0WL6uSr/a9sWjmJUk8ELG Y2wohAjfA7XhpVz3+KtH4mOcfpx5a5qzGfDDd6Fq1fk0a8M5hlC6A3qz8ihXT2qKQsHBf8wn0fdC/ hAkYSfxBR4uXbjEUY0o/g+0OVZvLLkT1jg3ndit4l2lyk9FykMd/HUjpXNtdOMgv5UCNBMwR4JbcG DM9ZCUsA==; Received: by zero.zsh.org with local id 1ojXNk-000Hjv-9E; Sat, 15 Oct 2022 02:58:36 +0000 Authentication-Results: zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none Received: from mta03.eastlink.ca ([24.224.136.9]:42182) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1ojXN7-000H4L-I7; Sat, 15 Oct 2022 02:57:58 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta03.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RJR0036TV8A98E0@mta03.eastlink.ca> for zsh-users@zsh.org; Fri, 14 Oct 2022 23:57:56 -0300 (ADT) Received: from [192.168.0.4] ([24.207.18.108]) by Eastlink with ESMTPSA id jXN5ojr1Llgn7jXN5ozOaK; Fri, 14 Oct 2022 23:57:56 -0300 X-Authority-Analysis: v=2.4 cv=NL8QR22g c=1 sm=1 tr=0 ts=634a21b4 a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=w7MfZzjFYp77HutLhkQA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekfedgieeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepiedtjeffvefgtdehgefgteekueeggeeitedutddvvdduteetffdvveelgfeukedunecukfhppedvgedrvddtjedrudekrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrddukedruddtkedphhgvlhhopegludelvddrudeikedrtddrgegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Message-id: Date: Fri, 14 Oct 2022 19:57:55 -0700 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: line continuation with sed To: zsh-users@zsh.org References: <9184bbff-9e68-7b02-2595-3474b016dfff@eastlink.ca> Content-language: en-US From: Ray Andrews In-reply-to: Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28213 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 2022-10-14 19:34, Aaron Schrab wrote: > Instead I'll give a method to help avoid the problem. For awhile now, > anytime I'm using calling a command with enough options to warrant > line continuation I build them up in an array instead. This allows > splitting across lines without using a backslash at the end, and > *actually* allows comments. > > This also allows the arguments to be build up gradually with some > being added conditionally. > > The below actually works as written including the comments: > >     args=( >       -re 's/abc/xyx/' # End of the alphabet is better >       -re 's/123/456/' # Bigger numbers are better >       # -re 's/foo/bar/' # Disable for now >     ) > >     if [ -r /some/file ] >     then >       args+=(-re 's/new/old/') >     fi > >     echo abc123 | sed "${args[@]}" > > For zsh you can just use $args to reference it, the way I wrote it > above will work in bash as well. > That is most clever!  As it is, when I have a long set of seds, I copy the whole thing, comment it, and then add comments (within the comments) so as to inform myself what the seds are doing since I tend to forget all the syntactic details. You method permits the comments where they naturally belong.  Mind, it seems to me that comments after a line wrap would be easy to implement but that's not what we have.  Thanks again.