Turn off subshelling of pipe

After searching the forum, I found that Bash spawns a subshell when using the pipe. I am wondering if there is an option or any other way to turn off this fuctionality.

We are pulling over some scripts from a Korn shell environment. I have found ways to work around looping from a pipe (Thanks to this forum!!), but we would like to not change this logic. We tried to invoke the korn shell (#!/bin/ksh93) environment but found that this version is old and unacceptable.

Any Ideas? Is there a switch or setting?

Thanks!

Please post an example code.

ls -1 2>/dev/null | while read LAND_FILE
do
...code
done

This spawns a subshell.

while read LAND_FILE <(ls -1 2>/dev/null)
do
...code
done

This doesn't spawn a subshell.

We would like to be able to run the first loop without spawning a sub-shell.

Thanks in advance

Just to clarify,
why you don't want to use process substitution (the <(...) syntax)?

Old? KSH-93 is the most recent version of the KornShel Language. It is also most feature-rich implementation of the KornShell. It's currently maintained and continuously improved by its creator David Korn and others at AT&T.

Consider that ksh93 is different from the other shells as far as the last command in a pipeline is concerned (it does not fork a subshell), just like you want it to be.
Consider the following:

zsh-4.3.9-dev-2[t]% bash -c 'echo OK|while read;do ok=$REPLY;done;echo $ok'

zsh-4.3.9-dev-2[t]% pdksh -c 'echo OK|while read;do ok=$REPLY;done;echo $ok'

zsh-4.3.9-dev-2[t]% ksh93 -c 'echo OK|while read;do ok=$REPLY;done;echo $ok'
OK

The Z-Shell behaves in the same way (as ksh93).

You may change this by enclosing the loop and all the following commands with braces for example:

zsh-4.3.9-dev-2[t]% bash -c 'echo OK|{ while read;do ok=$REPLY;done;echo $ok;}'
OK
zsh-4.3.9-dev-2[t]% pdksh -c 'echo OK|{ while read;do ok=$REPLY;done;echo $ok;}'
OK

Hope this helps.

>ls -1 2>/dev/null | while read LAND_FILE
>do
>...code
>done

following is what you could do to work around the subshelling:

while read LAND_FILE
do
...code
done <<EOF
`ls -1 2>/dev/null`
EOF