bug-make
[Top][All Lists]
Advanced

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

RE: GNU enhancement -- $(xargs cmd, list)


From: Howard Chu
Subject: RE: GNU enhancement -- $(xargs cmd, list)
Date: Mon, 6 Nov 2000 13:24:40 -0800

Try "xargs command < tmpfile" instead of "cat tmpfile | xargs command" ...

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc  

> -----Original Message-----
> From: address@hidden [mailto:address@hidden Behalf Of
> Reid Madsen
> Sent: Monday, November 06, 2000 12:29 PM
> To: address@hidden; address@hidden
> Subject: Re: GNU enhancement -- $(xargs cmd, list)
> 
> 
> 
> Well, I've got a prototype up and running and IMHO it's quite cool.
> 
> All changes are in function.c.  The net of the changes are:
> 
> * Added support for:
> 
>       $(xargs command, list)
> 
>   which is expanded to:
> 
>       cat <tmpfile> | xargs command; rm -f <tmpfile>
> 
> * Added 'func_xargs' as shown below:
> 
>     static int xargs_file_count = 0;
> 
>     static char *
>     func_xargs(o, argv, funcname)
>           char *o;
>           char **argv;
>           const char* funcname;
>     {
>       char buff[256];
>       char filename[256];
>       FILE* fd;
> 
>       sprintf (filename, "/tmp/gnumake.%d.%d.xargs", getpid(), 
> xargs_file_count++);
>       fd = fopen(filename, "w");
>       fprintf(fd, "%s\n", argv[1]);
>       fclose(fd);
> 
>       sprintf (buff, "cat %s | xargs ", filename);
>       o = variable_buffer_output(o, buff, strlen(buff));
>       o = variable_buffer_output(o, argv[0], strlen(argv[0]));
>       sprintf (buff, "; rm -f %s", filename);
>       o = variable_buffer_output(o, buff, strlen(buff));
>       return o;
>     }
> 
> This works perfectly!  Well at least it works perfectly within my limited
> understanding of GNUmake.
> 
> Additional considerations:
> 
> * On machines with dynamic command lines (i.e., Solaris), the $(xargs)
>   function should just expand to:
> 
>       command list
> 
>   No need for xargs in those cases.
>  
> * Allowing user definition of the XARGS command and options.  
> Something like:
> 
>       XARGS = myxargs
>       XARGS_OPTIONS = -blah -blah...
> 
>   with the defaults being:
> 
>       XARGS = xargs
>       XARGS_OPTIONS = 
> 
> Let me know if you want to integrate this.  Personally, I see 
> this as a very
> useful extension to GNUmake.
> 
> Regards,
> 
> Reid Madsen
> 
> -- 
> Reid Madsen                             address@hidden        
>               
> Senior Member, Tech. Staff              (972) 536-3261 (Desk)
> I2 Technologies                         (214) 850-9613 (Cellular)
> --
> Making incrementally (without 'clean') since May 18, 2000.
> Long live incremental make!
> 
> _______________________________________________
> Bug-make mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-make
> 



reply via email to

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