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 21168 invoked from network); 24 Aug 2021 13:06:28 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Aug 2021 13:06:28 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1629810388; b=FO7QX4lsAZkSexNxWiU51sGSSWlSMoqWIa5OwYXjDkS1qHJrdP2N7qeFnW9TVoiS4iK8aPnmqh yNAwbJqufBw3aKThVTL2dThQRc2mEP3fVqKcaqzjGXBWh2GDiMIdJhsN4P7wRh/D7Zrc2pFNS2 oszUCFgN9ki4I6TGXA+0D55kj67YiuHG/DsVnzXTR9tYnWBzN04vTq+4Cnhee4pTgOMTFRQ7yq 5GG2N1id4w2ix9ki0G1q+xHGkKevCmvJ4VhrHy3lNCJoWYVrjlnFwrJvhHOVCWhxuvRXg0/Ml1 045jXgA10A44VWIguwEkVU2kxFAE7lM+Ggqb02CdiF/2/A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 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=1629810388; bh=H5c31DOucKZiwb0bbip9f0WzLKSoFO/TuAF9YlwFUqs=; 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=ZsSqNLaVWZhplZO8fZqP4JeMiGEp9i3WitVXrLmQk6Fdq+2i8MC1QNyPKrCj22GF5XhRF/cWRf 7FOodrn/q8fDFr6kqD6cIw3TKK/JeM/No9eEXoiUYWVNry8KjWwlNSjrcN6+zFop4Ye3RqyjM7 +4fEnDc3H7cndY1X8dvs2bgGNvHDDBVv+6IeV2pZytacBZvw2eQZjHTKTZ4rSODxori5AMmReR veF5XKuTnsWqK8Uf5FD5rLS+JqX6aCTTiCEGnvOZ/kN+zWPFm8c65TMzcXgXt6OYAlgV7s6Wkk O7WbGoMTVZ2gy2yC5OgVqQ7ibjBhg1tbVQ5/5c6jRnl/Xw==; 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=RfdjkZ7TliK0tCVUiMuyAs6wBEFX6jjnOM93Crcpw+I=; b=D+GSXZqWWqJsc17hmkybhJQFTu B1bOCcbW4feScMydjLJjQIDPsLQ68jeoCwXdU9Dy3rHFC2+YuzhrlxNI+a2btthooNbTGmXVizhDd Y/RgdmRaLvtV+ZNz0cuVUXVLDtNVTvRvkU2vSKxmbRpGLVjmqG58aeNRgFfc4lYmkFSaNKRDRHDRf ewRV3X+ewuaT6zxCmSH1PudnQz5DTwG3zatICKo7LBm2Mo1plMRFHgCAKIFXZmDQWiwbkxNCT1poR FzHr/9Yxzv3PJ3jKP1WQQCbE+0agjjEo1fOeqSKHbGUVLDiASfwcfzrUgrLiZQKpKpy8arR3AseAj PambQXgw==; Received: from authenticated user by zero.zsh.org with local id 1mIW7o-000Nr6-SY; Tue, 24 Aug 2021 13:05:56 +0000 Authentication-Results: zsh.org; iprev=pass (out2-smtp.messagingengine.com) smtp.remote-ip=66.111.4.26; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out2-smtp.messagingengine.com ([66.111.4.26]:35477) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mIW6v-000NXj-9g; Tue, 24 Aug 2021 13:05:02 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id D18085C0161; Tue, 24 Aug 2021 09:04:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 24 Aug 2021 09:04:59 -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=RfdjkZ7TliK0tCVUiMuyAs6wBEFX6jjnOM93Crcp w+I=; b=ed10rZE+adCzNKo9D8F15ms8395ozjQJ/jFweQJACRwdA9pdJz8gA/A9 HuAW9K2mvf0l7BBH+HnnKPNsZwK1vpOSOGTBynVsXNjGAB0LZQROtUdRdt7WDtTb AMoEW1mjUtBz1E6YHecu/lWa7FHiiLql8AGeC6foL5KwuQUsKNWeRiF7RAJuRnyY 9aIxB00+iQT5i0Bz92Hb+ECGFQpIX4j6c6ut/Z9F7H+ZBZqj/JYErQNLa3/brFeF TmoNI8UAFxcgEa64R6SWhdNhypBiAV8GWA+CoUSS38nPw6RypAKX/AZVLtU3aCpN VSBDCe7KFDOLExglIzdk0bMp6hbyQA== 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=fm3; bh=RfdjkZ7TliK0tCVUiMuyAs6wBEFX6jjnOM93Crcpw +I=; b=f7RIoT1cLBjBjCDWpPsUpGo30O4ZUCKQ8pnXYFg8fi1cDeFwOcksJSqFp 1e5uEzB+txY1CiFNp/yc6IQVadO5QGz8b8Li118JmkBSHufqlUv5f1JiZgERGK6I Z7nw2Tt4syM2bZmsmzQp6p9RdiyQo6ceSgmKjWTbf1spKZtTFjO87EiDVY+cZL5H 2Q8barrzphEAkmemmANKdsIEPmnMc2XSAE63cC51/8MbMPv6txM1TnD5floHkPb+ OWf03jxrcB/lUgQ6XNVJXQ/+fvWUg0Z39SvZ6F76//++RzLfrl4ZY3fgad70MZfF MvEj3UViUDe8fbmciGkla+flugpKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddtjedgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtugfgjggfsehtkedttddtredunecuhfhrohhmpeffrghn ihgvlhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpefgleehtdffuefhgeeuleefffejgedttdelhedvvdeuiefh vefgvdfghfevvdekteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Aug 2021 09:04:58 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4Gv8Tj2Z3Mz4yj; Tue, 24 Aug 2021 13:04:57 +0000 (UTC) Date: Tue, 24 Aug 2021 13:04:57 +0000 From: Daniel Shahaf To: Peter Stephenson Cc: zsh-workers@zsh.org Subject: Re: [BUG] zf_ln complains about the wrong argument Message-ID: <20210824130457.GA31780@tarpaulin.shahaf.local2> References: <27858812.1079792.1629707601122@mail2.virginmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <27858812.1079792.1629707601122@mail2.virginmedia.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 49301 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: Peter Stephenson wrote on Mon, Aug 23, 2021 at 09:33:21 +0100: > > > On 22 August 2021 at 22:05 Daniel Shahaf wrote: > > Peter Stephenson wrote on Sun, 22 Aug 2021 20:24 +00:00: > > > Also seems a good idea to turn a null string into a couple of quotes. I > > > thought of modifying the error message handler but this has too many > > > knock on effects. > > > > What "knock on effects"? Extending zwarning() with a %q format code > > that takes a «char *» and outputs it quoted seems like a good idea and > > shouldn't break anything. Will handle filenames with spaces, too. > > This is certainly all stuff that's accumulated rather than been planned > over the years, but having a harder look I think it's mostly not too bad > the way it is. I think the basics are currently as follows. > > %s as implemented in errors and warnings is already not a straight > printf %s: it uses nicezputs() to emphasise visibility rather than quoting, > i.e. it's there to make it easy to see what the error is about, rather than > easy to copy back into the shell. Given the error is about something that > would usually be either in a script or on the command line, this doesn't > seem a bad way of doing it, on reflection. > Well, sure, %s doesn't have to use the an escaping algorithm that's inputtable back into the shell, but it'd still be nice if the escaping were clear and unambiguous. As it stands, printing «%s» doesn't escape or quote empty strings and spaces. > As far as quoting is concerned, the state of the art is to use `%s' (i.e. > with those literal quotes) if it seems necessary to draw attention to the > argument, i.e. it could get lost otherwise. There are a lot of cases > where we don't do this, however, but they can easily be changed. The > combination of this and nicezputs() means you can always see what's > there, unless there are very subtle cases I've missed. If the argument to %s contains literal single quotes then this is ambiguous. > So I think the consistent way of handling a case like this is to turn > %s into `%s'. That both makes it visible what's going on and makes > the output consistent with similar cases elsewhere. > > Does that seem reasonable? +1 > I can't think of a strong argument for a more widespread change given > it's sort of working and even sort of potentially consistent. Well, if there were a %q that did unambiguous escaping/quoting, it'd be harder to accidentally write zwarning("foo: %s: bar") in new code, forgetting to quote. And of course, filenames with single quotes would be output more unambiguously :) Cheers, Daniel