zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: xargs with zsh function
Date: Mon, 18 Jan 2021 15:09:53 -0800	[thread overview]
Message-ID: <CAH+w=7bO8GXUsd_nNyZtiZ63Pg6YcCwb8cz2ZGUwHK95iUX0Eg@mail.gmail.com> (raw)
In-Reply-To: <a1319762-f8d9-38c6-9471-b7d066bec1a1@eastlink.ca>

On Mon, Jan 18, 2021 at 2:14 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Playing with that running this script (test):
>
> $ . test
> xzargs: bad math expression: operator expected at `rap'

There's something in your test script you're not showing us; nothing in

xzargs() { zargs -t -- "${(f)$(read -d '' -E)}" -- "$@" }

would be evaluating a math expression.

> ... It works fine with a single literal input or a single string
> variable but I'd want to be throwing large numbers of lines at this.

The way xargs works is to gather up N lines until a "large enough"
argument list is assembled, and then call the command with those
arguments.  The way zargs works is to take all of those arguments on a
single command line and break them up into batches of N.

print -l "$vvar"  # this only prints one line, argument will be "mnt rap"
print -l $vvar    # This prints two lines, arguments will be "mnt" and "rap"

If you actually want to see this in action you need to specify that
zargs should only process one argument at a time.

% xzargs() { zargs -n 1 -t -- "${(f)$(read -d '' -E)}" -- "$@" }
% print -l $vvar | xzargs el
el mnt
howdy
el rap
howdy


  reply	other threads:[~2021-01-18 23:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17 23:12 Ray Andrews
2021-01-18  3:10 ` Bart Schaefer
2021-01-18 22:14   ` Ray Andrews
2021-01-18 23:09     ` Bart Schaefer [this message]
2021-01-19  5:18       ` Ray Andrews
2021-01-19 14:30         ` Ray Andrews
2021-01-19 17:52           ` Lawrence Velázquez
2021-01-19 20:27             ` Ray Andrews
2021-01-19 21:39               ` Bart Schaefer
2021-01-19 23:48                 ` Ray Andrews
2021-01-20  1:05                 ` Ray Andrews
2021-01-20 18:25                   ` Ray Andrews
2021-01-21  5:52                     ` Bart Schaefer
2021-01-21 19:55                       ` Ray Andrews
2021-01-21 21:50                         ` Bart Schaefer
2021-01-21 23:20                           ` Ray Andrews
2021-01-19 20:31             ` Bart Schaefer
2021-01-19 20:59               ` Ray Andrews
2021-01-20 16:27   ` Daniel Shahaf

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='CAH+w=7bO8GXUsd_nNyZtiZ63Pg6YcCwb8cz2ZGUwHK95iUX0Eg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=rayandrews@eastlink.ca \
    --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).