From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id d77121e6 for ; Sun, 2 Feb 2020 17:04:49 +0000 (UTC) Received: (qmail 25148 invoked by alias); 2 Feb 2020 17:04:41 -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: List-Unsubscribe: X-Seq: 45378 Received: (qmail 20435 invoked by uid 1010); 2 Feb 2020 17:04:41 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25713. spamassassin: 3.4.2. Clear:RC:0(209.85.221.46):SA:0(-2.0/5.0):. Processed in 3.321741 secs); 02 Feb 2020 17:04:41 -0000 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.221.46 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=YgyigMB0eawI09cp6urke5+OKi8L9L1pgTRQ1JzY2pU=; b=YS/6s16UUQwf1rLFevIotOrR2vp5A7tryLDx1WYp8cvyJYQUY+9BDWVebz0x3JX8vR rJ9UI2IODUnFKFF1JPEcVf2otg06hJux3wNaCE30d7tpL5N0D7SXpq55aBzj6zjkzofX r/i1R4nmemEvsUfguT8CoWd1sivj+ZNT5jf6XCR/J3E8IsyDCLDJa4cCF58CQ76x0TGL NyroZ8miYr83bNVmYGeTm7jx9fOutSDQKzCNvdDEXlg6ltyHTLsyEXbaPJq0HUIPUZit nn1gCAycbRrsSGus4B1fyn/6FMaoDiTKs5RNo6QlH/PBiFvusxq9KshzEZSe870rai5A XKrQ== X-Gm-Message-State: APjAAAVeAxxv7aZEZt27Ykf93D+XcUVhT9zNJlOWv+hBiXijzYWVrYUU nMmt6E/WgksSTq8DrcqJ3BOyRmfz X-Google-Smtp-Source: APXvYqwpP52uWaRhHJORr9SzIR2llGJ6Hnr6708EmQZaBRBNx9J6kXMhtpZ3oYrYAbhvyu2q+DKsxQ== X-Received: by 2002:adf:dc86:: with SMTP id r6mr10916749wrj.68.1580663043004; Sun, 02 Feb 2020 09:04:03 -0800 (PST) Date: Sun, 2 Feb 2020 17:03:57 +0000 From: Stephane Chazelas To: Daniel Shahaf Cc: Zsh hackers list Subject: Re: [bug] :P modifier and symlink loops Message-ID: <20200202170357.imwazvlz5eeudn6g@chazelas.org> Mail-Followup-To: Daniel Shahaf , Zsh hackers list References: <20200111170047.ifjsdd5lfeksqyaa@chaz.gmail.com> <20200201175740.lma5dxgwufk6fpeg@chazelas.org> <20200202081021.7c8aab22@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200202081021.7c8aab22@tarpaulin.shahaf.local2> User-Agent: NeoMutt/20180716 2020-02-02 08:10:21 +0000, Daniel Shahaf: [...] > However, in ${${:-"/tmp/loop/../foo"}} we can't meet the postcondition. > I think our options are either to throw an exception, like a glob with > no matches does, or to keep the additional components verbatim, as you > suggest. > > Intuitively I lean towards the first option. We aren't a CGI script, > where PATH_INFO is to be expected. If we can't return a path without > dot and dot-dot components and without symlinks, we should raise an > error rather than continue silently. However, I'm open to alternatives. That works for me, I agree it's a pathological condition that may be worth reporting to the user, and to do that, there's probably no other alternative than to exit the current shell process. > I think the first option could be implemented along the lines of: > > 1. Call realpath($arg). > 2. If it returns ELOOP, ... and doesn't end in /.. the . path components would have to be removed first as well. > call realpath(${arg:h}) and append "/${arg:t}". And what if *that* realpath() fails with ELOOP? Do we carry on with $arg:h:h? > 3. Otherwise, throw an exception (i.e., set errflag). [...] -- Stephane