Re: .ONESHELL enhancement?
Matt McCutchen <[email protected]>
| Newsgroups | gmane.comp.gnu.make.devel |
|---|---|
| Message-ID | <1254721964.2035.103.camel@localhost> |
On Mon, 2009-10-05 at 06:26 +0200, Ralf Wildenhues wrote:
> * Matt McCutchen wrote on Mon, Oct 05, 2009 at 05:15:25AM CEST:
> > On Sun, 2009-10-04 at 10:55 +0200, Ralf Wildenhues wrote:
> > > * Matt McCutchen wrote on Sun, Oct 04, 2009 at 09:51:25AM CEST:
> > > > On Sat, 2009-10-03 at 10:12 +0000, Ralf Wildenhues wrote:
> > > > > As another minor point, constructs used to avoid shell command line length
> > > > > limitations may break with this optimization.
> > > >
> > > > Is it still a problem to pass the shell a long multiline argument with
> > > > -c?
> > >
> > > Yes, but I'm not sure what you mean here.
> >
> > Maybe what I should have asked is, exactly what "shell command line
> > length limitations" were you referring to?
> >
> > I am aware that Linux limits the argument length. I tested on my
> > computer and the limit appears to be 131071 characters. IMO, any
> > command script even close to that length ought to be factored out into a
> > separate file, so I don't see that limit being a problem.
>
> Well, then we just have to agree to disagree on this. I believe that
> one goal of GNU programs is to avoid arbitrary limitations. We have had
> a bug report against Automake or Libtool (can't remember) where this
> limit was actually hit on GNU/Linux.
Are you referring to this, which I found by Googling for `automake
"argument list too long"':
http://osdir.com/ml/automake-gnu/2009-07/msg00053.html
In any case, you've persuaded me that make should support the use of a
pipe or temporary file. I also note that the argument and temporary
file are not interchangeable for all interpreters; for example, for a
Haskell script, "ghc -e" wants a single IO action while "runghc" wants a
module declaring a "main" IO action. It would help in this case if the
choice of an argument or temporary file were configurable in the
makefile. This feature then becomes orthogonal to .ONESHELL .
> > If there's any kind of length limitation with -c (whether from the shell
> > or the OS), possible alternatives would include running $(SHELL) and
> > piping the script to its stdin, or writing the script to a temporary
> > file and running "$(SHELL) TMPFILE".
>
> How come GNU make doesn't do this (on all systems) then?
Because it's slower, I imagine:
$ time bash -c 'for i in {1..1000}; do bash -c true; done'
real 0m3.708s
user 0m1.493s
sys 0m2.210s
$ time bash -c 'for i in {1..1000}; do echo true | bash; done'
real 0m4.369s
user 0m1.578s
sys 0m3.565s
$ time bash -c 'for i in {1..1000}; do bash <<<true; done'
real 0m4.434s
user 0m1.719s
sys 0m2.644s
--
Matt