Unbelievable pipe bug

Hi!

Maybe is just because I am a beginner, but I can't imagine, what is the cause of the following problem:

  • I have a postinstall script(~17 Kb), which will be called in the following way from an other global installtool:

...
cat postinstall.sh | sh > /dev/null 2>&1
...

But somehow not the entire script will be sended through the pipe, and I will get an error:

if [ "$ERROR_CODE" -eq 0 ]
then
# success
exit 0
else
# /bin/sh: syntax error at line 714: 'end of file' unexpected

Of course not this is the end of the script.

I have taked out some comments from the postinstall script, now it has ~14 Kb and now works everything fine.

I have tried out the original script with the above command (cat ...) from the command line, and there everything works. The problem come out not on every computers, so I have checked out the OS versions, but these are the same.

Had somebody before such an error?
What do you thing about it?

Thank you,
Jozsef

Useless use of cat. Why don't you do:

sh postinstall.sh
or just
./postinstall.sh

??

The original cat command is this:

cat ${INSTALLSCRIPTS}/global_function2.sh $scriptname | $SHELL -s $*

where $scriptname is my postinstallscript.
Of course I know, that there are many other ways, to bypass the problem, but the question is, why does not work the above form.

The tests show, that the summ of the lines from global_function2.sh and postinstall.sh can't be more than 715.
Maybe is something with the memory size allocated for the pipe.

Sorry about the other post. :smiley:

Best regards,
Jozsef

Well this certainly looks like a bug to me. The cat command can certainly shove data into the pipe faster than the shell can read it. When the pipe fills, the cat command should block until there is room in the pipe. If cat aborts instead, the shell is robbed of the rest of the script.

I know that for ls and ll *, when you have too many arguments, you can use "xargs" to take the overload of info.

Is there anything like that for this problem with pipe? Or am I just on a pipedream? pun intended...

:smiley: