Shell script loop runs out of memory

Adam Dinwoodie Adam.Dinwoodie@metaswitch.com
Fri Jun 1 10:09:00 GMT 2012


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.


More information about the Cygwin mailing list