read after pipe problem OSX10.4

I use read often in scripts to filter the right part into a variable like:

$ print "abc cde efg" | read k l ; print "k=$k, l=$l"
k=, l=

This works on linux and unix versions I work with. On OSX 10.4 this
doesn't work. I found a workaround but would like to know
why the original line fails. And I don't like the
$ print "abc cde efg" |& read -p k l ; print "k=$k, l=$l"
[1] 11299
k=abc, l=cde efg

Greetings, William

Your ksh version has a bug. The original is the right syntax. "read -p" should fail. It's for reading from a co-process.

try:

print "abc cde efg" | { read k l ; print "k=$k, l=$l" ; }

Thanks for the replies, Perderabo and R2007.

Perderabo, what is strange is that when I start a different terminal, or
a different shell, they all behave the same. I tried bash, tcsh, csh and sh.
I expect it has to do with the OSX darwin or BSD system. Also commands
like ls and tar are different. It took me some time to get colors enabled
and app-defaults installed right for keybord shortcuts. The csh results:

$ csh
[d213-102-60-49:~] relyveld% echo "abc cde efg" | read k l ; echo "k=$k, l=$l"
csh: k: Undefined variable.

Finaly, I tried zsh and this one works! But I don't know zsh and all my
scripts are ksh based..

zsh:
d213-102-60-49% zsh
which read
read: shell built-in command
d213-102-60-49% exit

ksh:
$ which read
/usr/bin/read

$ zsh
d213-102-60-49% echo "abc cde efg" | read k l ; echo "k=$k, l=$l"
k=abc, l=cde efg

Test result (ksh):

$ print "abc cde efg" | { read k l ; print "k=$k, l=$l" ; }
k=, l=

Greetings, William.

I would not expect this to work with sh, csh, tcsh, or bash.

In ksh, do "whence -v read". read has to be a built-in.

zsh has almost everything that ksh and tcsh has. Many ksh scripts should work on zsh. Or so I'm told... I have never used it.

I am in puzzle about this. Can somebody tell me why?