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 3289 invoked from network); 22 Aug 2021 20:25:12 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Aug 2021 20:25:12 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1629663912; b=gwXonZSjMhGGVUKduvamaLkSL6fTKPcQ0gW8hDxV4lbZuSkat4jqsihZLLfULm7ORhnVx3MTF0 glZwEXIh047UL3cI4KPjezj+ak+skKK0RfTcjsjrp09yLHQZGbqkkQ8owNT5GJZJrpeV5C3qvH yBdmAeRGGvkbrWRTuu7zHOdYgFNQhkqojEbak5VCCFaO7bKPd52LuaFE9kMC3h6duaWiJKiJdY etOhwERaAUVHiq5FRRfo25Fm2e/K57n5dpdElJibLLGG2QsDBAerp6h4aA1mBxWl0uck/b9RhN q6UumXCHtLN/ua22RlfG0wMYSklDyK+SBMkChkNa+GK0EQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq5.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.100; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1629663912; bh=lzQZXRQCmAlahWoM7RgQKPWUcX68q6hP1p8xdZu/iQ4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Content-Type: References:In-Reply-To:Date:To:From:Subject:Message-ID:DKIM-Signature: DKIM-Signature; b=COHwSPj7LHkh3eB0moXGifmxEuM8nGipb2UhUroTdw70fyUl/q6EzatBOU9KplP2oiZx0Jelk5 SNFi0wEGWfK5xvErg9hBUd30Ulw/vY6QZmKAsKf2+v7AHiz2Ihq0r3VsuC3H6u/FWHt+HSLbWl Ps5n2Fu6qNWiYcyG2BezGPHRw8FT/0q14jq5WEJZFoz7CvEaj6YmF4XPkozb7WwAITpskuQCfW i4NiZTjwUe/nmnWmBgZFH3klWYpzsha2VMBehFTH1+KpGwHbGRPn7QFfEq84KjkJJWOGcTsjjw khJo19EYIGCrPLZljFw53UlKbQJZCK53CHOnla7gSfBRjw==; 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: Mime-Version:Content-Type:References:In-Reply-To:Date:To:From:Subject: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=F2Lf/DA0/ofi0rCZRi+wVY4E9mv6HZA491S6M2wUn3I=; b=T3pUz4mwWfAb3HvqX/c8va+T2v 56sfYHBHCk3HUL5N+iKCaHFnCihTqA11eSBxREA1K1BrqiTqFaHBAMazIeuUMhQ8dx66pyD1mSjVS V5q67t7o/TJ3IJldQBaROufglVmZxol2utnVETzwgyNx8JQ0ApILlh21sf8YKOpqP5X7ufFffPn7c LToIQpZdzeWwgfxYZ75W9g4g17X6tOpRxIsXkA8lQb8DOxi4bZOpWt1QjoY0nwak1dta4hCrkOKmO FJxzhdQJHb3zjN46gibWBHDhT9vTBRF0A615bw1Eva2n1+btDLZdPRwbocqNrw84AcNwaDexPkfUU qffBZcBQ==; Received: from authenticated user by zero.zsh.org with local id 1mHu1n-000IjE-J8; Sun, 22 Aug 2021 20:25:11 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq5.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.100; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq5.tb.ukmail.iss.as9143.net ([212.54.57.100]:39602) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1mHu1U-000IQu-Ve; Sun, 22 Aug 2021 20:24:53 +0000 Received: from [212.54.57.110] (helo=csmtp6.tb.ukmail.iss.as9143.net) by smtpq5.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1mHu1U-0003gY-FV for zsh-workers@zsh.org; Sun, 22 Aug 2021 22:24:52 +0200 Received: from pws-Zeus ([86.7.189.51]) by cmsmtp with ESMTPA id Hu1Tm63eBRdC9Hu1UmIxqP; Sun, 22 Aug 2021 22:24:52 +0200 X-Originating-IP: [86.7.189.51] X-Authenticated-Sender: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.4 cv=Kp8uZUaN c=1 sm=1 tr=0 ts=6122b294 cx=a_exe a=mDzK/eG20+r+ucIvzJc7BQ==:117 a=mDzK/eG20+r+ucIvzJc7BQ==:17 a=IkcTkHD0fZMA:10 a=MhDmnRu9jo8A:10 a=rrg_xpk27EZm_IUPwwoA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1629663892; bh=F2Lf/DA0/ofi0rCZRi+wVY4E9mv6HZA491S6M2wUn3I=; h=Subject:From:To:Date:In-Reply-To:References; b=jJht/Dz+7u38zM1Db+FhJVGsYy7FHUO+NCqWMnU1nlFmvnDLDyd6896ioN3VdKAwF 2iK45ueOWyP8Ib8LO1iLuTzTvwlMfryRalU2FvTyMPvTPVN7UKXP9GLTtQfDu+oYHT mu7SO/OPAygdOB8BN5yJ7G1iU81ChrfOXNxcDxatcyaJxyCIXFDJL8Iqns3/DEGcTq a8GLoEQwxyN4YOGpTiAZdVogkPfSLon6wDrVu3W7aWHO+qCdx8kVqnLxSNno2bARgR /fpIn2sRoUW1wKNpJgMR5HxooapjJ2CTVr+HnxwF2xXlmjnoe89LKZj+hKyqLrqduw GEXOSykTRvvOg== Message-ID: Subject: Re: [BUG] zf_ln complains about the wrong argument From: Peter Stephenson To: zsh-workers@zsh.org Date: Sun, 22 Aug 2021 21:24:51 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfOq5r78PS8dBU+AbWxPzFhVz7eVX4UZ4RUEeLVYquHAr1mPEu2ZCNvKdNnhyikaxysq4OBaI7zP9ffIH2n5yjb8ghte/233ovIiRiC0gL1i1VX/WyWqJ FeK4sFXNermsEfS8/HeZnpXQwoiV0xNfr1rYQb2ufnrvBKi03jynk6zA2HQfTgnWT7yOb+sdsekDJQ== X-Seq: 49297 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: On Sun, 2021-08-22 at 16:45 +0300, Marlon Richert wrote: > When the second argument to zf_ln is an empty string, zf_ln mistakenly > reports that the first argument is a non-existing file or dir: > > % zmodload zsh/files > % touch foo > % zf_ln foo '' > zf_ln: foo: no such file or directory Is this good enough to detect cases like this? An extra stat in the error case should be neither here nor there. 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. pws diff --git a/Src/Modules/files.c b/Src/Modules/files.c index a1d6f6bf2..d4ec93624 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -346,7 +346,16 @@ domove(char *nam, MoveFunc movefn, char *p, char *q, int flags) unlink(qbuf); } if(movefn(pbuf, qbuf)) { - zwarnnam(nam, "%s: %e", p, errno); + int ferrno = errno; + char *errfile = p; + if (ferrno == ENOENT && !lstat(pbuf, &st)) { + /* p *does* exist, so error is in q */ + errfile = q; + } + if (*errfile) + zwarnnam(nam, "%s: %e", errfile, ferrno); + else + zwarnnam(nam, "`': %e", ferrno); zsfree(pbuf); return 1; }