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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18726 invoked from network); 11 Dec 2022 17:50:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Dec 2022 17:50:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1670781019; b=futTTTV543pqF6ytxl9I4xOyM2HNlXUfSsQKF0yTNti9++u3KwKCq+eBYQVpPtD1SHXpKasOZw RwtPC6OqMcOdKPnzEZLqA9bS6zQ9hmvgbDjpCUY1xmnkyUxwtJwI7ok3t6rQYpCjZWi2EJXe0Z cJGaLYCkYQYZRSpbFmoEF0aY5LO0Gxn1iWo46RFBznc5I7xY/xf7Idi/PrjOuXlZDtNDal5Jzf 9MmzHfoqwRpHUYhVrQAjZwfUY4Le3r68AQx/8ogODMX3S6y93VNfxmhAVlIteGz9apY7ZVgXNe e/Nabr1iL5toIDfM4xIOkApZi3PkYVhxzO85V4TUx8zEUw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1670781019; bh=j4RGyt9+EWNGcYmrbe0Cr9/iCraAKqyCM86LyL181do=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:Message-ID:Subject:To:From:Date: DKIM-Signature; b=Is8NnIfQsIL7aWtfpKY/aYJODR7epD8pkDXxtifxOmB9ZKgm1zw/VBz690duADNgnDLu46ZcbW Fj+P5Pen+CuEXlWrEhWpnhfXKGptukGLCa+4eqB6bmago3wqUTWuC1NRYpZ/ZiaXXJpjJt+yp1 vRoqtZfaxDiujpHGs00U/za5vJ9pGrFTeLt9Ol8HMO/v7Tc3x4+sZsY3ZBq62gmcqfUHkL74vj AhM2k2PyaN6DJnkLUyzleNZoEZmL3jOZVvdnjscilyYbkSr8qEMqe4yUr9p3jnm6+G0cO4PKv1 yZRdT8TUt1+xIR25HYMSxhp8IXyBiqrspkrS0iB6+0Adpg==; 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-Type:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=81di8WQxhQWxNoBQzNaTDDgqHn4oVGKZVTIfDuEbvDA=; b=bnq9Z/zcFejFweqH/mfR9SYFtW gQENBH8MGNcmThkbQVSif3KMMYXwdO1itoA1hOrDwC2z2mSC0qXIISoXe32SC2BvSw8FhZC7VXuyn D8qmQwn07hUXmkTZXLmqaiiB29NV0YWql1lwjfmMpqzy1TX6TOEZ9OmelwgjJ4S2NgPyfihnAiclu k0Dnx9/AJCVE5aIIpQ+P3ZGSUDsx61cG+WtCiu+Lm27GjOk6ckVqw1+b8L7G/TtC+1oQQo+sRb3iB bj1IdaLYKZv1yk/AjykiS+vG1p/S4UJD6ptMiLi6IR1rSiQyHe7le4Vlc33A4gu+qSeA/agsQlIVm 6Z3vf8+g==; Received: by zero.zsh.org with local id 1p4QSw-000PYB-E5; Sun, 11 Dec 2022 17:50:18 +0000 Authentication-Results: zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none Received: from relay1-d.mail.gandi.net ([217.70.183.193]:55393) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1p4QSi-000PFc-SN; Sun, 11 Dec 2022 17:50:05 +0000 Received: (Authenticated sender: stephane@chazelas.org) by mail.gandi.net (Postfix) with ESMTPSA id 356B8240004 for ; Sun, 11 Dec 2022 17:50:03 +0000 (UTC) Date: Sun, 11 Dec 2022 17:50:01 +0000 From: Stephane Chazelas To: Zsh hackers list Subject: a='foo"'; echo ${a/foo"/"bar} outputs bar Message-ID: <20221211175001.u7dqfrnnzylsbjan@chazelas.org> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Seq: 51185 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: $ a='foo"' $ echo ${a/foo"/"bar} bar Whether quotes should escape the "/" is not clearly documented, though the doc does tell us to use backslash for that. However the fact that the first " is taken as being part of the pattern while the second one is removed doesn't make much sense. In ksh93, bash and mksh, quotes can be used to escape the /, i.e. one can do: $ a='/x/y/z' bash -c 'echo "${a/"/y/"/+}"' /x+z $ a='/x/y/z' ksh -c 'echo "${a/"/y/"/+}"' /x+z $ a='/x/y/z' mksh -c 'echo "${a/"/y/"/+}"' /x+z Maybe zsh could align with them? The csh-style one looks better: $ a='foo"' zsh -c 'echo ${a:s/foo"/"bar}' bar" quotes don't escape the / either but at least the " is to taken as part of the pattern. Better than tcsh anyway: $ a='foo"' tcsh -c 'echo ${a:s/foo"/"bar}' ^C^C^C^Z zsh: suspended a='foo"' tcsh -c 'echo ${a:s/foo"/"bar}' (148)$ kill % (ended up using all my RAM). -- Stephane