Re: Incorrect use causes sh.exe to spoon infinitely

Johannes Schindelin <[email protected]>
Newsgroups gmane.comp.gnu.mingw.msys
Message-ID <[email protected]>
Hi,

On Sun, 26 Jul 2009, leledumbo wrote:

> 
> Try running this buggy script:
> 
> for fin in `ls`; do
>   # notice the missing backtick (`)
>   fout=echo $fin | sed 's/\..*//'
> done
> 
> And (quickly) open task manager, you'll see a lot (and growing) of sh.exe
> processes.

This is really a PEBCAK: "fout=echo $fin" is a valid invocation of $fin 
with the environment variable "fout" set to the value "echo".

I am pretty certain that your "ls" returns a couple of shell scripts, and 
they are executed.

Now, why the number is growing, I can only guess that the forks are the 
issue (the sh.exe processes executing $fin not dying as quickly as the 
sed calls return), but that is pretty normal, given what you asked shell 
to do.

Ciao,
Dscho


------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.