This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Shell script loop runs out of memory
- From: Adam Dinwoodie <Adam dot Dinwoodie at metaswitch dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Fri, 1 Jun 2012 10:06:14 +0000
- Subject: RE: Shell script loop runs out of memory
- Deferred-delivery: Fri, 1 Jun 2012 10:06:00 +0000
- References: <loom.20120531T193933-322@post.gmane.org> <CANs8wdBYOBGsmp2iFSSOOd5FZ4qb3i3a-E2EM8LBbPKz=su5Pg@mail.gmail.com> <786EBDA1AC46254B813E200779E7AD36023A42C2@srv1163ex1.flightsafety.com> <loom.20120531T211830-607@post.gmane.org> <0105D5C1E0353146B1B222348B0411A20A770C827D@NIHMLBX02.nih.gov> <CE9C056E12502146A72FD81290379E9A4360C73F@ENFIRHMBX1.datcon.co.uk> <CANs8wdChyOK7p9zph=g1_jVsNVvg9n+D+srPGJCNYs75=KNKuA@mail.gmail.com>
AZ 9901 wrote:
> So some things to avoid while (bash)scripting under Cygwin to limit
> BLODA effect :
> - | : pipe stdout --> stdin
> - $(...) : subshell fork
> - `...` : same as before, subshell fork
> - [ condition ] : prefer [[ condition ]] construction
> - anything else ?
By my understanding of the discussion, any sort of forking, ie anything that
will require the bash interpreter to make a system() call. In particular,
including pipes in the above is somewhat of a red herring, since it's not the
pipe that's the problem, but the commands either side of it.
Calling any sort of executable (script, binary, whatever) will cause a fork.
Anything that requires a subshell (in bash, that's the subshell forks, the
( ... ) command syntax, etc), will similarly require a fork.
Shell builtins (eg echo) almost certainly won't require a fork. Note that not
everything you might expect to be a builtin is, however: bash doesn't have a
"sleep" builtin, for example. You can check whether something's a builtin by
calling "type command" from the bash shell.