From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4979 invoked by alias); 22 Apr 2016 05:55:25 -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: 21476 Received: (qmail 2125 invoked from network); 22 Apr 2016 05:55:24 -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,HTML_MESSAGE, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benizi-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=wySx39cmc8fMnHOb7TPBm2x/Q/mgJUigTgfOsjGw5b4=; b=FzkIiLcWUq3zuygZU9X572jCtReXxHWSGsEBw9zEGZc1z2UiJP0+hoGWX8qtwuwhIu B26hki3ALLZPPyltux8gsfA4xI2TjX54ODvPzXVtlNJhlDYLdg7Q8ldkDKGRF/tfXsD0 +n36ZGTHFKuljGQ22D1ZcjjQLNcN9TS6p8SmFw6aj+7A5i2c641+Z8KLmmR0yI2Dm3ZN LASb2Pb7WijErlMeugxUS/n48LXkm2ty5UEK6Cvg7vpp5wMJRE/ZDhMiFU7pUlXK2wGS +jNpmPsdt11URSTfWKfYjXdLeddgG7vX8w+sJoKR3IlO2zILdHkOTR7S90r5N4qkYnbx xJTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=wySx39cmc8fMnHOb7TPBm2x/Q/mgJUigTgfOsjGw5b4=; b=UF9b9RG7beqvjRclQ1loe8rxv2CLhdGaRmx1lylXxScPXXEeyAbGpUvvpq3OFn6S69 3IRGmh+l0lrG/gGVoL5PQnVxis6ox492r8fmZkABywPNpGkjETkrYAiyu+e0jiDUnjy/ W814XwEKnYNnXseF/tlHqkJn9PD23Mi5Iu2xp2A0Nsh1H9SL7EywQJxRgmBp0rD34aPw Ezglgr22DByZ1GBF5XRMcql+pOfr1lJxN9MQRO03EkMNR9w00zymoWSTplhT0u3vcn7G tQ4q0Rrp/UtIalwmbzPx4xrAn4H6quhsu6tl65gEkToHbZ6al4z1TlCjMO7NuZ/kFy8B Wrcg== X-Gm-Message-State: AOPr4FXTNEXHClPHAflkcx3klPfTBMLs9JfvFLLQSxHIDhwxLDxs923FGF7tOiHGR2KYRdV80ekrfmFl3FD25w== X-Received: by 10.157.13.227 with SMTP id 90mr8597372ots.79.1461304522320; Thu, 21 Apr 2016 22:55:22 -0700 (PDT) MIME-Version: 1.0 Sender: benizi@benizi.com In-Reply-To: <87zisneh10.fsf@student.uu.se> References: <8760vdrt5y.fsf@student.uu.se> <87zisneh10.fsf@student.uu.se> From: "Benjamin R. Haskell" Date: Fri, 22 Apr 2016 01:55:02 -0400 X-Google-Sender-Auth: VKOgosP19n0L4Au9qTMr6FemW8s Message-ID: Subject: Re: virtual files? To: Zsh-Users List Content-Type: multipart/alternative; boundary=94eb2c110014f647ff05310c7822 --94eb2c110014f647ff05310c7822 Content-Type: text/plain; charset=UTF-8 On Thu, Apr 21, 2016 at 12:12 AM, Emanuel Berg wrote: > "Benjamin R. Haskell" writes: > > > [...] > > () { > > local tmp=$1 > > wget -q $link -O $tmp > > echo -n \$ > > grep \"answer\" $tmp | cut -d \$ -f 2 | cut -d \< -f 1 > > } =(:) > > } > > [...] > > Only remark is, if you do all this trouble to get > clean code, and then name the local "tmp", it is > almost comical. I like to think of it as a lingering code smell. Don't need a tmp file after all. ;-) [...] > > awk '/"answer"/' | > > awk instead of grep in this context should be strange > to many who are more familiar with grep, but grep has > the problem that many like to put colorization to it > which can screw up parsing. If the configuration > is in an environmental, I suppose not even giving the > full path to the binary to bypass an alias would get > them away. One can supply a specification, of course, > telling grep not to use colors, but rather than doing > that, I switched to awk as you suggested. > I tend to prefer awk for a few reasons: 1. Whatever I wanted to `grep` usually needs some small amount of post-processing. (not in this case, but usually scope expands.) 2. It's often one fewer pipe than a `grep ... | cut ...` 3. In a lot of contexts it's nice that it doesn't exit non-zero even if nothing matches. 4. Its implementations tend to be very consistent (no worries about GNU vs non-GNU or Linux/other that often arise with other utilities), so it's a good command to learn. I also changed the two cut:s for tr, and date +%Y from > the `one` syntax form into $(another). > I strongly favor $(another) due to its nestability. [...] > One interesting thing is tho I changed three programs > out of three used, I don't think this function is > anything "remote" to the one I originally wrote. > A small homage to the diversity of the Linux/Unix > tools, I suppose. But come to think of it there are > many players in the NHL that score some ~15 goals > every season, but that doesn't mean they cannot also > be completely different players, physical aspects as > well as those of skill and style... > I noticed that I'd changed all the tools you used, too. It's also fun to notice that (maybe?) 5 years ago, I probably would've used Perl for the whole pipeline, but these days I pretty rarely fall back to it. -- Best, Ben --94eb2c110014f647ff05310c7822--