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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 0b7dec2a for ; Tue, 18 Jun 2019 13:38:19 +0000 (UTC) Received: (qmail 27144 invoked by alias); 18 Jun 2019 13:38:14 -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: 44422 Received: (qmail 20281 invoked by uid 1010); 18 Jun 2019 13:38:14 -0000 X-Qmail-Scanner-Diagnostics: from wout1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25482. spamassassin: 3.4.2. Clear:RC:0(64.147.123.24):SA:0(-2.6/5.0):. Processed in 4.715269 secs); 18 Jun 2019 13:38:14 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:subject:content-type :content-transfer-encoding; s=fm3; bh=/5vTSLpZ+IhLBwGsQSq1MFpxIs sGysvQE2r9CmhM094=; b=tiaVflIOIAEghMGLLA20VIjLDJaHTaW362hvn7CBwF XH4mG3gZeMevj6+mzKaV8FqVdtqSxwyyD81YbD/oF7ZtMYfKKXPFOVnZyHtXcyuY ZAFoTl0Iv9z88wG3r500Yi6iRwuhuWpLEm4ee4+yYpOZ613SOYuf1SH/TTdybH0X gbqGglS8RxmMRI0qnNdhh5zpBarhpCK5mhWdPQm8RACSU43+dmkNAExuI2FLO0zD lj5zFrYchjgDXCOy5rXjiew6cnDNjF9V7H1oC3ujGGUGMkPWnPpTtYZZhXtR3lON jLLfpEi+73R7UO+nvTvZTLx8DzCh+8rdFQJaANihIYsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=/5vTSLpZ+IhLBwGsQSq1MFpxIssGysvQE2r9CmhM0 94=; b=UdKYIIiN27ZKHKqxEyUMnxwZhV08I9Bcq5LZtNmWDP0PNdX1lW7EHRGKQ oBtGimdtYkJ6lkVWlQ7qVx1rrEmAZwEtwPW3ny6oR0pHuvKNAPMY+UWShE2/m7Oj n6uHGxbj+cYURc1LC7D+f85YMq4yOklDuetYSPsJ6s3n1Upne4r2znrc51GB+Mrd JpWAGu0/Nm2le2gdOYiPzlum9GuSjQxwfMaqLHDG/uxGw6FDSwHI2+AgJiG8YezF oWHFI2YoJrlGp3wD3qVWGBMC9AmeBMXxl7ywkLwNi8BPqukA3bKh/f397MDeeTf8 dM3gqC8QaX9UhAV+lUOdwynzfQPTw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrtddtgdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgfgsehtqh ertderreejnecuhfhrohhmpedfffgrnhhivghlucfuhhgrhhgrfhdfuceougdrshesuggr nhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenucfrrghrrghmpehmrghilhhfrhhomhepug drshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvnecuvehluhhsthgvrhfuihiivgep td X-ME-Proxy: X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.6-666-gb2312fa-fmstable-20190614v4 Mime-Version: 1.0 Message-Id: <523ba6f0-651a-444a-8ceb-c7c4ec186b20@www.fastmail.com> In-Reply-To: <1560862806.7731.11.camel@samsung.com> References: <1560862806.7731.11.camel@samsung.com> Date: Tue, 18 Jun 2019 13:37:30 +0000 From: "Daniel Shahaf" To: zsh-workers@zsh.org Subject: Re: PATCH: trailing components Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Peter Stephenson wrote on Tue, 18 Jun 2019 13:01 +00:00: > I needed to preserve a number of trailing components of a path (other > than one) and couldn't think of an easy way of doing it. =C2=A0Rather = than > craft obscure pattern substitutions, or use an ad-hoc expression to > strip the prefix, I came up with a patch to add an optional number aft= er > the "t" in history style modifiers to do this. =C2=A0I put it after ra= ther > than before because history-style colon expressions are quite sensitiv= e > to what the first character is after the colon. >=20 > Before I come up with tests and fix up the ensuing failures, you can l= et > me know if there's a better way of doing this to save me the trouble. Here are some alternatives, but I'm not claiming any of them is better t= han =C2=AB${foo:t2}=C2=BB: f() { REPLY=3D for 1 in {1..$1} ; do REPLY=3D$2:t/$REPLY; 2=3D$2:h ; done } f $N "$foo"; foo=3D$REPLY or foo=3D${(j./.)${${(s./.)foo}[-$N,-1]}} (plus or minus handling of runs of several consecutive slashes) or tmp=3D$foo for i in {1..$N} ; do tmp=3D$tmp:h ; done foo=3D${foo#$tmp/*}