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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13056 invoked from network); 15 Oct 2022 02:41:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 15 Oct 2022 02:41:08 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1665801668; b=Zf7AmhBtQEb1XGXG79/xo4BpZ3H9Rts7YqetFLxCGrasei3spkb9Od2onRqahaYzwMkMKUuNtU GY2rCcerYGoR4To7A1A5y9ePLkEy3ejp+bZVYuOmw9P1Q69G9L8+X6A91snDX19AZfBjcUAkrL 50i/JvQeSD0GsLv23PbV/T01nI2SRgDQa86A69//tz0vSbHs4KbEHfUnIhPCBgUI4p1h14Ly5C NGgmIm32qODJKAKmeY3GRALhB0gMslaqm0Yiq8uTDWg64hhc2Z2Xp6OFpT26RNbMPq6Brc40U3 NvYKxF+vtPgKZMM9ATp4RseeLm/BQTmocwk73MRNMM+qsw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (new3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.229; dkim=pass header.d=schrab.com header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=schrab.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1665801668; bh=zJxb6+A7eaxYLj1hek0FQvOsfLZmD7EqI3DFudgqv/c=; 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=Eu0GXD1ixwGYBiQucmkkQP0kbPbxXYgGQaK/nUlKjq7mjyqH3DbXqKQXQW1AEOAeatd0jbDh3j SasVoZ6hDCNhfFNAf81Fj//nu3gw2MuMfsGql5NwlZaYR0QQPsNYPtfsbevbH0VHjbB//jRk6a uq7dc1EVykuXl826z0OxU1MXr/cwIc1oO5U6sceKri9sPHG8fXyEXIX5cVkcgNCAacXXDxZ7NM UPJfS+9ktKO9a+FqBbWeBsu8lKTbMitdz9KagclxIuRHZGQyoe9H6vBWnnT9QQM/h8RKzMTX7L Afg7gilml3mDXybIK2RpVdcqgZAauQSlsd/9K8Xu5fal0A==; 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=KTz6alnWZGfsUWFx/RQPbWsNMoV4FUfBOGP+GeqemDM=; b=SuhYV4/Jl8HNmSXF3X+zPdV3sl bFyZCHViaGbVgaCMRQJn1oBa0JxAD0MxqP3FubQ2orjOwMwj+xgCoyR0ysiuk2neKIOBHarNWub01 csVR4t7nTUDPDjSRgJksKLby98L8JMINMRAsiIwKbNQdc7MywiVKA127kwWRvrrOOWbMZ5jyqhVtO esihU6bX5IgKCQRXGS21+3blh2wGq/bK9UleO0LNV9k7NprUtjxAHTeYABNn9JblpX/62v3dcK9sZ hDzYXIoFynrbQ0uJcVGk7SCznKEuOFdeyPKCOHgXqTZ/uUtSj0qSJN2jV6OV6T7DcDW/L5KMd8N6A 5dXlYXKQ==; Received: by zero.zsh.org with local id 1ojX6o-000GGR-U8; Sat, 15 Oct 2022 02:41:06 +0000 Authentication-Results: zsh.org; iprev=pass (new3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.229; dkim=pass header.d=schrab.com header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=schrab.com; arc=none Received: from new3-smtp.messagingengine.com ([66.111.4.229]:58195) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1ojX0V-000FQu-SJ; Sat, 15 Oct 2022 02:34:37 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 49CA3580110; Fri, 14 Oct 2022 22:34:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 14 Oct 2022 22:34:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schrab.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1665801272; x= 1665804872; bh=KTz6alnWZGfsUWFx/RQPbWsNMoV4FUfBOGP+GeqemDM=; b=J uYXcJ9Uw56VtDiZAjCDJZBtmKyijuNwbAlCE/wG0cHf8TDJkXkHlL2rqUvMKdgRq hQ7fuJGHvlS/7zhEBjoU7JQA8QAI++88rk4b2PDALZbh2T2uf93X8w2UZiLWVlzq okilTfGL8vexGWNR4adWTpfiKdGC6+KjN8Kdl+igX7LRbk1LqEqQuMwXYjJX9hML OOaArwRcBnYnBSs6hWltTKbvORt6Ee8Ni3Rqx+Qc9LPR2uNfHCLRLJk1YtfeDEJM gH3nizW+56zyrUmCFh8gBYWn1Vq4DtN/EbQon2/1aHAPMLB+GEyf/+N5DVBXuZIe 9DG74m2U1WlX0u2tbREDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1665801272; x= 1665804872; bh=KTz6alnWZGfsUWFx/RQPbWsNMoV4FUfBOGP+GeqemDM=; b=n PnLwbftKfH7ASoMeBNq1mmhHLZafYgsUMwXvoBGnC8OdA59tE2eyBciQnGifWdfK OIqlbtYMOUBF3Pb/EaBHS6oGhb0eqB6D6sIzDIlaK9M91PK60ondfTzumcZB+GLJ 9g00NCzSoRdzX8Z/sNRoWrbBfDGlwF5UTgnX9bU2rG6DtLGHlJkl3iLTq88xYsKY 9sqD8mgwJBgT8TyUAPecGB7TM7UOark+RPOifkNNXxrVoxBhmBBGKhpPCeQ5VSkI EmDJ6NkBpw6ZzufUiDAwUuo5jQahTUtPRd6bbyS60GAy6jMmHFduG0p/vGo4YGnA lQ8zB0yd8OR6uv1XrxqLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekfedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetrghr ohhnucfutghhrhgrsgcuoegrrghrohhnsehstghhrhgrsgdrtghomheqnecuggftrfgrth htvghrnhepvedvgedtheefgeekffffveefieeifeeghfekfeethfdtvefhjedtgfegveej vedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg grrhhonhesshgthhhrrggsrdgtohhm X-ME-Proxy: Feedback-ID: i1fd14616:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 14 Oct 2022 22:34:31 -0400 (EDT) Date: Fri, 14 Oct 2022 22:34:30 -0400 From: Aaron Schrab To: Ray Andrews Cc: Zsh Users Subject: Re: line continuation with sed Message-ID: Mail-Followup-To: Ray Andrews , Zsh Users References: <9184bbff-9e68-7b02-2595-3474b016dfff@eastlink.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9184bbff-9e68-7b02-2595-3474b016dfff@eastlink.ca> X-Seq: 28212 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: At 11:25 -0700 13 Oct 2022, Ray Andrews wrote: >I'm wondering if this is a zsh issue or entirely sed's fault but: > >$ var=$( print -l $var | sed \ >-re 's/.../' \                                 # this is fine >-re 's/.../'\                                  # this  throws an error >which I'd expect >-re 's/.../' \                                  # this throws an error ... >-re 's/.../' ) There have already been a number of replies explaining this, and hints on how to detect this, so I won't address that. 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.