Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: xargs with zsh function



On 2021-01-17 7:10 p.m., Bart Schaefer wrote:

How about this:

$ autoload zargs
$ xzargs() { zargs -- "${(f)$(read -d '' -E)}" -- "$@" }
$ ... | xzargs my_function


Playing with that running this script (test):

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

   function el ()
   {
   echo howdy
   }

   vvar=( 'mnt' 'rap' )

   print -l "$vvar" | xzargs el

------------------------------------------
$ . test
xzargs: bad math expression: operator expected at `rap'
el mnt rap
howdy

... 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.  I know the receiving function might have to be feed them one at a time, which is easy, but I can't get zargs to swallow more than one string.





Messages sorted by: Reverse Date, Date, Thread, Author