www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/08/16/20:14:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Mon, 16 Aug 2004 20:13:50 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Hans Horn <hannes AT 2horns DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: igawk problem
In-Reply-To: <cfluvo$hfj$1@sea.gmane.org>
Message-ID: <Pine.GSO.4.61.0408161959540.6952@slinky.cs.nyu.edu>
References: <cfj317$os8$1 AT sea DOT gmane DOT org> <Pine DOT GSO DOT 4 DOT 58 DOT 0408132323001 DOT 594 AT slinky DOT cs DOT nyu DOT edu> <cfluvo$hfj$1 AT sea DOT gmane DOT org>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

On Sat, 14 Aug 2004, Hans Horn wrote:

> Igor,
> 
> thx for your good idea to look what igawk is doing under the hood.
> So I tracked things further down and found that the problem is one line 
> further down than you thought, and does not seem to be cygwin/windows 
> specific (doesn't work under AIX either):
> 
> The real bad guy is:
> eval gawk $opts -- '"$processed_program"' '"$@"'

Hans,

I meant that the long line that's passed to gawk was constructed at the 
line that I named as culprit.  That long line should not be passed on the 
command line.

Try changing the commands in lines 129-133 to something like

tmpname=`mktemp`
gawk -- "$expand_prog" /dev/stdin <<EOF >$tmpname
$program
EOF
eval gawk $opts -- -f $tmpname '"$@"' \
  && rm -f $tmpname

Or

gawk -- "$expand_prog" /dev/stdin <<EOF | eval xargs -0i gawk $opts -- {} '"$@"'
$program
EOF

Or even

gawk -- "$expand_prog" /dev/stdin <<EOF | eval gawk $opts -- -f- '"$@"'
$program
EOF

though the last will probably not work well when the input also comes on 
stdin...
HTH,
	Igor

> The following workaround works under cygwin :
> 
> ###############
> tmpname=`mktemp`
> echo "$processed_program" > $tmpname
> gawk -f $tmpname
> if [ $? -eq 0 ]; then rm -f $tmpname; fi
> #################
> 
> Interestingly, this doesn't work under AIX.
> There, the command
>     echo "$processed_program" > $tmpname
> replaces all "\n" in the code (that may occur in printf statements), with 
> explicit newlines.
> 
> Unfortunately, I don't really understand fully what the construct
>     eval gawk $opts -- '"$processed_program"' '"$@"'
> other than passing '"$processed_program"' to gawk.
> 
> If you can offer any further isight, I'd be very appreciative!
> 
> cheers,
> Hans
> 
> Igor Pechtchanski wrote:
> > On Fri, 13 Aug 2004, Hans Horn wrote:
> >
> >>  Group,
> >>
> >> I have a rather lengthy awk script (that internally includes a bunch
> >> of awk library functions; therefore I'm using igawk).
> >>
> >> When I invoke it, e.g. like
> >>
> >> echo | igawk -f script.awk
> >> eval: gawk: argument list too long
> >>
> >> The script and the awk library functions together make up approx.
> >> 34kByte.
> >>
> >> Does anybody have a clue whether I'm running here into a hard shell
> >> limit, or some internal limit of gawk?
> >
> > This looks like an upstream igawk portability bug -- the lines
> >
> > processed_program=`gawk -- "$expand_prog" /dev/stdin <<EOF
> > $program
> > EOF
> >
> > look like the culprit.  They should be using xargs instead...
> > This is a Win32 limit, and it has to do with the fact that gawk is
> > invoked using Win32 calls by default.  There are a few solutions, one
> > of the easiest being to "mount -X" your /bin and /usr/bin
> > directories.  Or, you can fix igawk to use xargs and submit your
> > patch upstream... ;-)
> > Igor 

-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019