From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23358 invoked by alias); 15 Jun 2016 22:37:59 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21668 Received: (qmail 2185 invoked from network); 15 Jun 2016 22:37:58 -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=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 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=YMMv0zMkLOZRoFl6SEtES5i45sRq94IgR3gGQmbfBuY=; b=I8EOemNaJxyzcT+2RLfKnf6SDHPPVyH2vvwIuKj6/IKA5sgi/xew/J6RVzBy6uYMA0 9tbqiE99ufOdHlxpXzL/AYF+3Qsv/zbTYrByMbbtvn/ESZf/NCnzVHSf5lbwFVwlnQpb joSBKluurhKrhG01MUXgs2oTnoM1iFdHDWlWFCPMxkPquQUyYnWXizap6pKavbDA2oVx Is8uEohF7cFEJk1PSmPqCr/2AdGOs3856Ar4GqlO0/YNx3Zx3nEdPVGbrW6/r1O7/FY4 Oq/nvIYSGJKbjmvyRrhs6ARCjaMJQNB+Rum8kwYaPylqyKMO2Vl2dw1Kka7dD+Sf1HCg 89IA== 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=YMMv0zMkLOZRoFl6SEtES5i45sRq94IgR3gGQmbfBuY=; b=J1IL7GlJQqaEHx53PbHnJI4Eft+3ujRBEq7ppamcKqXU28k44V2asbrqnJXNwU9jhB jZJc7srJnpPGpliVt4kgeAUk7sslEx6yt+MeoJY2nXb8kHWq4rylA6Wfm45X+8FFkjgQ lBJ6zvmgsgUDJ3+LWHZAu+kDt6BleHSaK8DckxbVLhxF/RyPREvPLS4bCwJO9zNbZIOR bIPR6h3a5Rb1U3LcUL9JnhafyyE02U9oI2zCXGu7sQLiuAoCKn/WX5huFsJIZAEmgrgm l1A+bVl0spvDB02z3AmI5xYv1GyT9D6+f9AhiPGM4kSiUZagWri6KCdlIzvo5uSv5Veg XhEA== X-Gm-Message-State: ALyK8tLJ42JC5OYG45ip597i3sENOOiidEcvAP0YDrcfv3mjfkBJxJQILnItjKvzOKKHcg== X-Received: by 10.66.182.194 with SMTP id eg2mr1164991pac.159.1466030274950; Wed, 15 Jun 2016 15:37:54 -0700 (PDT) From: Bart Schaefer Message-Id: <160615153817.ZM22021@torch.brasslantern.com> Date: Wed, 15 Jun 2016 15:38:17 -0700 In-Reply-To: Comments: In reply to Mikael Magnusson "Re: Feature request: two level sorting" (Jun 15, 8:25pm) References: <160615101239.ZM21280@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: Feature request: two level sorting MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 15, 8:25pm, Mikael Magnusson wrote: } } Can we do what the oe:: flag does for globbing? Ie, pass each element } to a custom code snippet that transforms it arbitrarily, and sort on } the output. We considered that a while back, but the problem is that if you allow arbitrary shell code to be called from within the sort algorithm there are way too many opportunities for madness. With globbing, there's one well-defined place -- the read of the name from the directory structure -- where the callback can be applied to a single data element. With a sort, the callback may be invoked many times for pairs of data, sometimes even more than once for the same pair depending on the algorithm, and unlike e.g. perl that has object pointers and reference-count garbage collection and lexical scopiing and a whole other panoply of protections against the user shooting himself, in zshell code all sorts of havoc could be wrought. (Yeah, you can probably create the same havoc in perl if you work at it, but it's a lot more difficult.) Falling back to something lesser/safer amounts to inventing a whole new mini-language. It's just not worth it to internalize in the shell something that (a) other languages do better and (b) was intended by the original architecture to be done in an outside process anyway.