help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: working around "execvp: echo: Argument list too long"?


From: Dave Korn
Subject: RE: working around "execvp: echo: Argument list too long"?
Date: Wed, 10 Sep 2008 12:51:27 +0100

Matthias Wenzel wrote on 10 September 2008 11:03:

> my problem is I have a large list in a make-variable. I want to process
> each element of that list (individually). But any attempt with
> shell-loops ends up in the same error, and GNU-make-wise I am not
> getting there.
> 
> Note that I don't need to echo the variable all in one go, but instead
> do something with each element. However I am lacking the propper syntax.

  :-) Sounds like you need something like this:



File: make.info,  Node: Foreach and Xargs Functions,  Next: Call Function,
Prev: Conditional Functions,  Up: Functions

8.5 The `foreach' Function
==========================

[  ... snip! ... ]

8.6 The `xargs' Function
========================

The `xargs' function is very similar to the `foreach' function.  It
differs in that it allows more than one substitution to be performed
into each of the repeated uses of the text.

   The syntax of the `xargs' function is:

     $(xargs FLAGS,VAR,LIST,TEXT)

The first three arguments, FLAGS, VAR and LIST, are expanded before
anything else is done; note that the last argument, TEXT, is *not*
expanded at the same time.  Then, one or more words at a time from the
expanded value of LIST are concatenated into the variable named by the
expanded value of VAR, and TEXT is expanded.  Presumably TEXT contains
references to that variable, so its expansion will be different each
time.

   The result is that TEXT is expanded many times, each time with one
or more whitespace-separated words from LIST, until all the words in
LIST have been exhausted.  The multiple expansions of TEXT are
concatenated, with spaces between them, to make the result of `xargs'.

   The FLAGS passed to the `xargs' function control the way in which it
assembles words from LIST into VAR each time it expands TEXT, and are
similar to the option switches available to the `xargs' command-line
utility.  Each switch must be concatenated to its argument to form a
single whitespace-separated word in FLAGS.  The recognized options are:

     `-nMAX-ARGS'  - set maximum number of words to assemble
                          in VAR per expansion of TEXT.

     `-sMAX-CHARS' - set maximum number of characters to assemble
                          in VAR per expansion of TEXT.

     `-l'          - append a newline between each of the multiple
                          expansions of TEXT, instead of a single space.

     `-L'          - append a newline and a TAB between each of the multiple
                          expansions of TEXT, instead of a single space.





    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....





reply via email to

[Prev in Thread] Current Thread [Next in Thread]