zsh-users
 help / color / mirror / code / Atom feed
From: "Lawrence Velázquez" <larryv@zsh.org>
To: zsh-users@zsh.org
Subject: Re: the splits
Date: Wed, 22 May 2024 20:04:31 -0400	[thread overview]
Message-ID: <527f680d-6c71-4eb0-9586-bb4cd253b76e@app.fastmail.com> (raw)
In-Reply-To: <8b434c8d-4618-49bd-998b-72644a2727fd@eastlink.ca>

On Wed, May 22, 2024, at 5:36 PM, Ray Andrews wrote:
> Of course.  Yes, different tools for different jobs.  What I meant was 
> that it terms of priority awk might have given me more bang for the 
> buck as the first tool to learn.  Mind, sed is simpler and that's why I 
> went that way.

Yes, it's quite common -- borderline universal -- to start with sed
and pick up awk later.


> Tx. for links.  'Strength reduction' is something I 
> believe in instinctively.  I always want to do things in native zsh 
> code if possible.  External tools have to justify their weight.

You take this way too far, in my opinion.  Compared to appropriate
external tools, zsh-heavy solutions often perform poorly and are
more difficult to understand and maintain.  (Compare your original
code to the awk solutions Mark and Roman offered.)  Most of your
code would improve if you (judiciously) used more external utilities
and less zsh.

(For example, when you find yourself doing this:

	output=$(cmd)
	lines=(${(f)output})
	for line in $lines
	do
		modify_line_and_print_it
	done

you should step back and consider ''cmd | sed'' or ''cmd | awk''
instead, especially if cmd might output more than a couple of
lines.)


-- 
vq


  reply	other threads:[~2024-05-23  0:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 17:42 Ray Andrews
2024-05-22  1:48 ` Mark J. Reed
2024-05-22  2:21   ` Ray Andrews
2024-05-22  5:56     ` Roman Perepelitsa
2024-05-22 19:25       ` Ray Andrews
2024-05-22 20:41         ` Lawrence Velázquez
2024-05-22 21:36           ` Ray Andrews
2024-05-23  0:04             ` Lawrence Velázquez [this message]
2024-05-23  0:30               ` Ray Andrews
2024-05-23  2:31                 ` Mark J. Reed
2024-05-23 12:58                   ` Ray Andrews
2024-05-22  5:57     ` Jim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=527f680d-6c71-4eb0-9586-bb4cd253b76e@app.fastmail.com \
    --to=larryv@zsh.org \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).