From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21786 invoked by alias); 30 Sep 2016 04:29:32 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39509 Received: (qmail 10507 invoked from network); 30 Sep 2016 04:29:32 -0000 X-Qmail-Scanner-Diagnostics: from mail-pf0-f174.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.192.174):SA:0(0.0/5.0):. Processed in 0.770855 secs); 30 Sep 2016 04:29:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=WiPIUwMcEZwsu67qAc1iXT53OA9PcVDxbZ65cEiC7lE=; b=GnsefXEMtrm5yley4J8ikWUFd92CZOBvX6K/svdMvTYeGBza9Y0mqdL35gN34Q9XMZ PV3MyiqLAkz1QNJXfhotLNRkc1ygnvwvFghjXnKpQ7geyTGNKeOhs6Ts/o7XoKEj/+IU xgEhcXzO+4zp0yaxy6ujEjaGptpAyr4sLYuqPpCvcUhQ11wgUTk39BYqi14fqANl0eHj p85b1w8bhi+OKpE0upZyrRQ7kJXC2aEsnG/v9JhZZUyo6XrNG+Q7or4b8pQKwAPdGzEJ DLRFYy9ps2s2ypj1yCAzZB5LhCn96w2Lzx0KqL0+kn1zAFwI92AKksA+bfinpPMmzTno sJ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=WiPIUwMcEZwsu67qAc1iXT53OA9PcVDxbZ65cEiC7lE=; b=D3uag2EaZJsq2Wx/SSJZXntPrLLHXPyLCL+yCwNxbn7L3B10SNyCNDVO90P/LogSWx EV5JZaUrMBSrdn7jxu3dqrYafSqX9/wLURR9IFFJnK7rf68h1BRBzyAiacvO5+IuZ5Fy 3jR3hFPFKJj399aCEtd0h5A+0MYd/rZpaXgMnXSrcO3x4f+5Vk2yypOYdsikBKklN98c 3nOWWRWe7Ocr3nK8cT5hrN4x6KeY2Zw6hb7T0aoxp37R9JBSUZDZdPKP70dkqX3Ype3o hxeiRkrqNCYanQTG//p7VkO0lW44Epv6478sUpwpUYIsvfYabO7fgwc4eN+5hn+rizKF 9HMQ== X-Gm-Message-State: AA6/9RkWq5kxy+a56XMu+pF57RxIvhn3/hANnhUWznxWDYf67rmwmzrNfOpHsTHVDqdQeg== X-Received: by 10.98.90.133 with SMTP id o127mr8096992pfb.61.1475209765042; Thu, 29 Sep 2016 21:29:25 -0700 (PDT) From: Bart Schaefer Message-Id: <160929212943.ZM28332@torch.brasslantern.com> Date: Thu, 29 Sep 2016 21:29:43 -0700 In-Reply-To: <20160929092357.6ebb6463@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: a bug of zsh" (Sep 29, 9:23am) References: <20160928160419.4fab20f5@pwslap01u.europe.root.pri> <20160928170746.0495d8f6@pwslap01u.europe.root.pri> <160928121010.ZM32336@torch.brasslantern.com> <20160929092357.6ebb6463@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: a bug of zsh MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 29, 9:23am, Peter Stephenson wrote: } Subject: Re: a bug of zsh } } % ./foo } % pwd } /export/home/pws/tmp/foo } % rmdir ../foo } % pwd } /export/home/pws/tmp/foo # cd .. still works here } % cd . } % pwd } . # but now "cd .." would require chase_dots } % } } That seems a reasonable minimal fix. I haven't looked at the code. Try it this way? diff --git a/Src/builtin.c b/Src/builtin.c index c78fd9b..60dc07f 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -1273,7 +1273,23 @@ fixdir(char *src) #ifdef __CYGWIN__ char *s0 = src; #endif - int ret = 0; + /* This function is always called with n path containing at + * least one slash, either because one was input by the user or + * because the caller has prepended either pwd or a cdpath dir. + * If asked to make a relative change and pwd is set to ".", + * the current directory has been removed out from under us, + * so force links to be chased. + * + * Ordinarily we can't get here with "../" as the first component + * but handle the silly special case of ".." in cdpath. + * + * Order of comparisons here looks funny, but it short-circuits + * most rapidly in the event of a false condition. Set to 2 + * here so we still obey the (lack of) CHASEDOTS option after + * the first "../" is preserved (test chasedots > 1 below). + */ + int chasedots = (src[0] == '.' && pwd[0] == '.' && pwd[1] == '\0' && + (src[1] == '/' || (src[1] == '.' && src[2] == '/'))) * 2; /*** if have RFS superroot directory ***/ #ifdef HAVE_SUPERROOT @@ -1305,12 +1321,12 @@ fixdir(char *src) while (dest > d0 + 1 && dest[-1] == '/') dest--; *dest = '\0'; - return ret; + return chasedots; } if (src[0] == '.' && src[1] == '.' && (src[2] == '\0' || src[2] == '/')) { - if (isset(CHASEDOTS)) { - ret = 1; + if (isset(CHASEDOTS) || chasedots > 1) { + chasedots = 1; /* and treat as normal path segment */ } else { if (dest > d0 + 1) { @@ -1348,6 +1364,7 @@ fixdir(char *src) dest[-1] = *src++ ^ 32; } } + /* unreached */ } /**/