From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29314 invoked by alias); 30 Jan 2016 15:34:46 -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: 21209 Received: (qmail 8325 invoked from network); 30 Jan 2016 15:34:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=nmhHI8bkH0ZP9OJ50ioTZG/oABPQhaOjZbD6Je3/H7Q=; b=dLDpMZPylkYPYf1jzVe9hOz7QIeC0C4KeOEpYnNuM6BhHAh4+3srSn6Jirh6hgKsNq JcoTDDgxg54RUzAu7pA6VUxkresAtaan7NV0AO/Uo/crwCW9RSV6Trv/q0d7v9PEahqs DCt6E4Xi6HSts+kceK/JVjafkP/JKW8h/rfmhaSUMvgAkeePmom0dmEJAhG4DlBLAqHx nS0JGiKq5UWjNs61IsiESekuRkrmOzHySHXmdOoOpwUjgPpiRWlJO991F9aKeZYeyw8X UyrjHphKJKH6OnVuXefFAg5eM91d3otFL7TblzHpZ4vI7i372+s2PIVWb7rcBAvJyoHe PIYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=nmhHI8bkH0ZP9OJ50ioTZG/oABPQhaOjZbD6Je3/H7Q=; b=a8XkkcRi4ij7v5tNTcmRr+amFgc0jVkFm+l9qZJTcYI2k2Qdj3l8n7ivcPX70qHt97 NVRhRYvD5xumzBT8u1axUdabIZLuLW/3PgQDEbZc0QwzuYcWFo9boDX3A8FZcq8T7pHf WZRTemqMHlqSYw1TdLbnqYZV3GvVzl2aOoHH3VkWLC0iDJAUlcCbLlU/6d15nbevKTz/ 70VANff+QzceZ6giD0/UXz4A5i9B25DBbrqLQeoehbM1/tlsAnCannDFT1dRce43r9sQ qM3AA1MljYGi8un5NrvHghIb4+jh0eCxgfP/md+DbnuDU6OyD0OidwQ/KDZYYgqcSgPc BvZQ== X-Gm-Message-State: AG10YOSG6gy93jtSXOoVIU2UkAk3lICiohIko33puIbaa0xkAkkt64Uq3beBXfTuggAvV7HkCZPDUZAPm+wPtw== X-Received: by 10.25.151.9 with SMTP id z9mr4515665lfd.72.1454168081397; Sat, 30 Jan 2016 07:34:41 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1454164684.1526.25.camel@gladbachcity.de> References: <1454164684.1526.25.camel@gladbachcity.de> From: Sebastian Gniazdowski Date: Sat, 30 Jan 2016 16:34:21 +0100 Message-ID: Subject: Re: Feature request (@M):# with context matches To: Christian Heinrich Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 30 January 2016 at 15:38, Christian Heinrich wrote: > Hi Sebastian, > > I'm not sure what you want to do, but I my guts tells me that you want > to re-invent the wheel as you stated that you want to replace several > tools with ZSH. If you can achieve your goal by calling a GNU tool, you > should do that. These are mature tools and there is nothing wrong about > using them. (And it's certainly a benefit that you don't have to > maintain them.) > > Calling "grep" is also more understandable by everyone than the pattern > you gave in your first email. I'll try to contradict the "more understandable" with an example =E2=80=93 antigen, a probably very well written BSG code. Take this function for example: https://github.com/zsh-users/antigen/blob/master/antigen.zsh#L100-L112 antigen-bundles () { # Bulk add many bundles at one go. Empty lines and lines starting with = a `#` # are ignored. Everything else is given to `antigen-bundle` as is, no # quoting rules applied. local line grep '^[[:space:]]*[^[:space:]#]' | while read line; do # Using `eval` so that we can use the shell-style quoting in each l= ine # piped to `antigen-bundles`. eval "antigen-bundle $line" done } For me it's hard to understand this function. Grep, forks, pipes, evals. My point is that this is what "$( )" leads to in general. That's what ABSG advises to do, and such code is spread everywhere, across companies, open source projects. Other example: https://github.com/zsh-users/antigen/blob/master/antigen.zsh#L347-L355 # Find directores in ADOTDIR/repos, that are not in the bundles record. local unused_clones=3D"$(comm -13 \ <(-antigen-echo-record | awk '$4 =3D=3D "true" {print $1}' | while read line; do -antigen-get-clone-dir "$line" done | sort -u) \ <(\ls -d "$ADOTDIR/repos/"* | sort -u))" This is one candidate to most outstanding BSG snippet in the project. On the other hand, such programming is maybe something distinct from typical imperative programming. With my "GNU -> zsh" document, I would maybe advocate how to do normal programming in Zsh. But I believe I wouldn't, Zsh has it's own unique traits, own ways of compressing much into little of code, without use of Awk. Best regards, Sebastian Gniazdowski