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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22398 invoked from network); 24 Oct 2021 01:41:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Oct 2021 01:41:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1635039661; b=XBLvLxqDcWEYAVGDMqVaQO3rRA07XZ+51pBllMwv4jZUNx3Vux6OAVEEj1KtfaLG4v74lWkCC5 OhmaWx4P+hQLoO88jkCpPdeMTwn/iHF5h/NDdqV0BTj04tF1CpCUsPqdwRaZu0E3++xvoyqpsO 1lLXHrkCwy9JYlEKX3yQ+8K3MZkoEYI/rK+NCYb9N8ojVDv7EAaiZmMo9bIpWB2XSNYRqVOuRx e4LZdwq3XyCM8d26bLD/DDn7Jh/tkvjKqY6mUaeCjNBr3V0Xn9fyIXy7mC61UFVYapUkM+IXlt sH1NhfvIhcv/Us8gOuqmlPtlvA+UFXFgyWlT8t1BZH37jA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.17.20; dkim=pass header.d=gmx.net header.s=badeba3b8450 header.a=rsa-sha256; dmarc=none header.from=gmx.de; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1635039661; bh=ZBQorjYRMbjjWUEAr4YXbCk76uhoWeP16Szm/Y7HAQ8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:In-Reply-To:Content-Type: MIME-Version:References:Reply-To:Message-ID:Subject:To:From:Date: DKIM-Signature:DKIM-Signature; b=pqfyyLMhe/NHsejWwjmfp5+0/p1Vn9rnslA3+P/WUxMAeHvyVFn0dcLkaTC35BFRQ7+63YUnMu 6OwWh51zNESM8yekZrFuGUA7y6B3dsHGG9fHdLBf6g7oyzvqL4Wn7Vkf4ANBjeuFm78NmaVGn3 leCrthpYFF+9DRfmAgYOqIu9i0YFaSoXeaEb240obIXAjITzZTipna/BcOdFg0LcEM+k5oyVfn l5x3PVKeFxxVFm/zE6pg85y8dK2t501yqtk6F4tOizqe1raenBtOs/AgbvBXj2mQQ1gP2XBauY uEjihen0vOEnTbI4NrNwRoe5uvD19JteMwZTmz8Yjs+OXg==; 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:In-Reply-To :Content-Type:MIME-Version:References:Reply-To:Message-ID:Subject:To:From: Date:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=a+RvF2M3R9RvfVkorvF4kufDBorCKPJXpp6kwjv9cGg=; b=mKdA/NcshPnjOdT1uWRa1mDUpV Qk47SorWPgBAy88yDn+4WE94NVKTNF+LychpPLSazYpnV6HU5ATTuLmColglEtB5vyu6J6zrh3Hdq x0rWpMi5qQV/oYt/DclbDUN+Gg8fiJO+cpwdQ5ZRxwqrd1Lgtp57eMaRRUVaPH/dP0luoe2/qSgml H/0DywlWlqwmfYT5o2YLRxcYp7bYoz0C12n/oATN/eLXl6/xhstdxOK3r4Q9QZ2exD2iZSU2xroXs ERmi85ewcRk/kAbNM9WxFL11d3I2YYsHg/NH2T3XtMRkOMiu0O6+HtF5KsK7eSSkWdZUbDlGQZoPg 2lLM//VQ==; Received: from authenticated user by zero.zsh.org with local id 1meSVR-00089v-5l; Sun, 24 Oct 2021 01:41:01 +0000 Authentication-Results: zsh.org; iprev=pass (mout.gmx.net) smtp.remote-ip=212.227.17.20; dkim=pass header.d=gmx.net header.s=badeba3b8450 header.a=rsa-sha256; dmarc=none header.from=gmx.de; arc=none Received: from mout.gmx.net ([212.227.17.20]:46093) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1meSUZ-0007Ql-5j; Sun, 24 Oct 2021 01:40:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1635039606; bh=ZBQorjYRMbjjWUEAr4YXbCk76uhoWeP16Szm/Y7HAQ8=; h=X-UI-Sender-Class:Date:From:To:Subject:Reply-To:References: In-Reply-To; b=WWHP4QLepFftf+S/WoLXy3kYxS6CsOuUmHwOtKaPe5jLqqi6hdwR2mNvS4yu+DX1x cM7wSBCmtaaB9nws8hh1DYHmRkkrzzX7sYWnO4RNMm6yKYspBoeSu2hHZf4aDgwU+S WjMHWJ7bx3p0QfDAUuP1n/0gMSkEY/ka79Od8D/Y= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from zitrone.obstwiese ([46.223.163.252]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MRCKC-1mHPpC1Ag8-00NAiY for ; Sun, 24 Oct 2021 03:40:06 +0200 Received: from luthien by zitrone.obstwiese with local (Exim 4.94.2) (envelope-from ) id 1meSSH-0002Ab-Q1; Sun, 24 Oct 2021 02:37:45 +0100 Date: Sun, 24 Oct 2021 02:37:45 +0100 From: Dominik Vogt To: zsh-users@zsh.org Subject: Re: Most Recent File Message-ID: Reply-To: dominik.vogt@gmx.de Mail-Followup-To: zsh-users@zsh.org References: <20211023164338.GA6763@gmx.de> <095002061dc32afdfb1dcfe51e1171e23e62375d.camel@ntlworld.com> <20211023172445.GA8911@gmx.de> <0b757d10f1a2374d5a84199fbed71314e16fea63.camel@ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:YUVqopbJmR/xZPTzIz27W08lNW08G91IAwPQY8LdfJ1VRhHMPDb isJegMnMrfpLvtjvAZvLd5xafQZJQnjLNx+1svkBcEN8hkevhN0o8L/UoEhKu0Q1gzPxsKu QicfXo7WJIEF7Dt6WJsRCd2OHHzuQhojxbCFM8Fd9pzdtqWls05vWusL3grXjMKi6pWOVse IsLPpxlCE4i9dJTVo8Ucg== X-UI-Out-Filterresults: notjunk:1;V03:K0:6MMDArOyCQs=:imP5U62wKZf96AOqnTEEM7 4HYuuovGw+kRpd3aw/bMk1fe1Jk+x1GH1Ex2keaXBmT8ZOxMd7JKtPcGya0p3Pw9BM05i4FIV KH5mG8m5CO0fYrpCaRXNDWVdthSLgU7k5Q0uYAY/8OvnVtrg6e9KJMDQ1Tp6np0/NTOpZAhuc Iw7swjX5ovuxTaLT5cvUWDW/ginD3eqRUTEFHsWvaXqO+/WTBfuigHw6aHLH8QgKLwuzLRoUm sL4PyTZWkrlIiz11+ieQqoBk2PtONEnoeCkkWdmcuuCLQydxX8o3tct3V0eXfmmb2yDdMslTU E7Dc193N7jH2YZGPojqQ9U9ZugLtDgWTWaTguViNw3JFIsHdlclwsSa/MrNEML4rhpI5F6Sup hjg59xXwtRobXdKRRYmhUwT7TkWLqEFCVl0SomEVGkafUcXKky20z5hE7fQyP869OSBVnDlP4 DznSwicwSGFyKzH3IBmCQ5D3+xXuPjtWi9VfX5l1oB46IB3wCO6DP+x6LVAwTjsG8ieNhsF0x e6kHy1zBwCPlCVPFA1iVQOmTfe2qlphBHbyDS6t2PjdoWm6Mfrr/Wl/9g2s1HpoaawWzcDkr5 OED4iki6jLTIBtm0XElXdn3gFLVkm7yxQQijkiPArlxuqQ4wJQCnRXNySnKVlZ90c7/Bcpdjo wwNQgnSpLhMRCJjuIEFHAXKyXtB1sqZ/D4ZznQRmpIRuLiWtcKdPlYyDAG4RDYtus6vT1MXBi dUvT6VzaMUCwxUPqFlGVh1ex4dtVKfFlTwHqZEaCQhkrVjdd7HvQ8eUx2RxFL/O6gUpZgc/J1 mzqblSHmqHKnMqtYYz2Z0ZNMB6H/tUdn1GWJ+Pc7brpJ7r+wjvCLiDjMvEkN0KGv13iw90fV/ li4kqSs4jAMnmGEqoyOGhfCOOtiSXDcU49irb1CQamaFTbo/nQOtRxt9TgP2F4OM08Jb54Z5K NXX1JxJESZaQ5ALpMFoOhWcrxypgVH0SrVI7EGkSmsSminkR+HuLanWJTt8hVYZGSNZLzAEUq 2Pp+M3LM0Jn/F0osgTpd2ceJL2BE4MNRxSPm91o17grlFU90RDy9xbJHM/SNO0L2cP5p6wWqP BD/qwoqKQZo/kE= Content-Transfer-Encoding: quoted-printable X-Seq: 27281 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Sun, Oct 24, 2021 at 02:24:04AM +0200, Pier Paolo Grassi wrote: > >That doesn't work because if one of the file names has a newline in > >it, (f) will split it into two words. (Also I think you left out an > >open paren.) > > sorry about that, I haven't ever considered newlines in filenames, since= I > wouldn't put them in the first place. Maybe just stop putting spaces in filenames. Unix systems are cluttered with scripts and other programs that cannot handle whitespace, asterisks, hyphens, semicola and other charaters with a special shell or program meaning anyway. (The vast majority of people forget to put variables in double quotes in their scripts.) Passing funny file names to programs is asking for trouble. In the worst case it can destroy or compromise your system. You could try this solution where the most recent entries are automatically put into an array (needs some work to deal with * matching nothing): precmd () { __recent=3D( *(-om) ) } $ ls -- "${(@)__recent[1,3]}" Or if it's only about ls, you could write a function "ls-recent" that implements the logic. The suggestions with "eval" or automatic unquoting of values may be a path to disaster. Ciao Dominik ^_^ ^_^ =2D- Dominik Vogt