Subject: /bin/sh problem with field splitting and parameter expansion
To: NetBSD current <current-users@netbsd.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: current-users
Date: 06/07/2004 19:55:35
Hi,

I just noticed some field splitting problems after parameter
extension, in a /bin/sh `for' loop ...

It seems that there is no field splitting with default value :

njoly@lanfeust [~]> /bin/sh 
$ for i in a b c; do echo $i; done
a
b
c
$ for i in ${x-a b c}; do echo $i; done
a b c
$ x='x y'
$ for i in ${x-a b c}; do echo $i; done
x
y
$ 

But ksh, give another result, which looks better to me :

njoly@lanfeust [~]> /bin/ksh 
$ for i in a b c; do echo $i; done
a
b
c
$ for i in ${x-a b c}; do echo $i; done
a
b
c
$ x='x y'
$ for i in ${x-a b c}; do echo $i; done
x
y

njoly@lanfeust [~]> uname -a
NetBSD lanfeust.sis.pasteur.fr 2.0F NetBSD 2.0F (LANFEUST) #5: Fri Jun  4 10:09:03 CEST 2004  njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST amd64

Did i missed something, or this a bug ?

Thanks in advance,
Regards.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.