ksh command grouping and file-descriptors

From: Serge MUNHOVEN <munhoven_at_mema.ucl.ac.be>
Date: Thu, 02 Jul 1998 17:49:20 +0200

Dear Digital UNIX gurus,

While modifying a script for POSIX-sh, which happens to be ksh, I
came accros a problem which melts down to what is reported below (sorry for
the lengthy output).

Note that:
 - POSIX/ksh was initially required for some features not available in sh;
 - command grouping (...) is required because the actual script is more
   evolved than a simple while-do loop;
 - the current version now runs under plain sh, so there is no longer a
   problem for me.

I'd just like to know if this is "a bug or a feature", or just bad shell
syntax on my account ...

% cat readabc
echo "=== ... << ==="
while read A B C; do echo $A $B $C; done <<EOF
a b c
x y z
EOF
#
echo "=== ... 9<< ==="
while read A B C <&9 ; do echo $A $B $C; done 9<<EOF
a b c
x y z
EOF
#
echo "=== (...) << ==="
(while read A B C; do echo $A $B $C; done) <<EOF
a b c
x y z
EOF
#
echo "=== (...) 9<< ==="
(while read A B C <&9 ; do echo $A $B $C; done) 9<<EOF
a b c
x y z
EOF
#
echo "===EOF==="
%
% sh readabc
=== ... << ===
a b c
x y z
=== ... 9<< ===
a b c
x y z
=== (...) << ===
a b c
x y z
=== (...) 9<< ===
a b c
x y z
===EOF===
%
% ksh readabc
=== ... << ===
a b c
x y z
=== ... 9<< ===
a b c
x y z
=== (...) << ===
a b c
x y z
=== (...) 9<< ===
a b c
===EOF===
$

Oops, where did the second line (and following ones if there were) go ?
With more evolved input and from a file rather than a here-document, I get
even stranger output.

OS: Digital UNIX 4.0D + most of jumbo patch #1

Thanks in advance for any comments,

 - Serge

-- 
-                                                                             -
 Serge Munhoven                              Internet: munhoven_at_mema.ucl.ac.be
 Universite Catholique de Louvain               Phone (office): ++32-10-478032
 CESAME - Applied Mechanics Division                (division): ++32-10-472350
 Av. Georges Lemaitre, 4                                   Fax: ++32-10-472180
 B-1348 Louvain-la-Neuve (Belgium - Europe)                      Office: a.011
-                                                                             -
Received on Thu Jul 02 1998 - 17:51:08 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:38 NZDT