"Cai Qian" <[EMAIL PROTECTED]> wrote:
> For following code,
>
> sh <<EOF
>       read
> EOF
>
> I have no idea why will not block.

The "read" command reads from the shell's stdin, which is the here
document.  At the point where the "read" command is executed, the
shell has already read the "read" command from the here document, so
the next thing read from there will be end-of-file.  If you want the
"read" command to read from the original stdin that was present before
the here document was introduced, you can copy it to another
descriptor:

sh <<EOF 3<&0
    read <&3
EOF

> So I can run some Perl code inside like,
>
> perl - <<'EOF'
>      XXXXX
>
> EOF

With perl, it may be easier to use -e instead of a here document:
perl -e '
    XXXXX
'

Then perl will still be connected to the original stdin, without any
need for duplicating descriptors.


paul


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to