Subject: Re: "for" behaviour in /bin/sh
To: I presume I need no introduction. <>
From: Johnny C. Lam <>
List: current-users
Date: 07/13/1998 11:18:58
> I'd say that NetBSD's sh doesn't catch this is a bug, but only by the
> "virtue" that no other Bourne Shell that I've seen behaves thusly.
> 				--*greywolf;

So is the "correct" thing to do to replace

	for f in ${LIST}; do
	  echo $f

	for f in ${LIST} ""; do
	  if [ X"$f" != X"" ]; then
	    echo $f

?? Is there a better way to do this?

I notice that /bin/sh in FreeBSD and OpenBSD behave like NetBSD's.

I discovered this variance in behaviour of NetBSD's /bin/sh when I
ported our pkgsrc system to HP-UX. relies on the /bin/sh
accepting an empty list in the for loop for trivial cases.  [ As an
aside, in, we often use ".if defined(FOO)" when we really
mean to say ".if !emtpy(FOO)" .]

   Johnny C. Lam
   Department of Statistics   
   Carnegie Mellon University