Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Mar 2000 09:23:22 +0100
From:      Martin Cracauer <cracauer@cons.org>
To:        Max Khon <fjoe@iclub.nsu.ru>
Cc:        Martin Cracauer <cracauer@cons.org>, John Polstra <jdp@polstra.com>, Doug@gorean.org, hackers@FreeBSD.ORG
Subject:   Re: empty lists in for (/bin/sh)
Message-ID:  <20000306092322.A14710@cons.org>
In-Reply-To: <Pine.BSF.4.21.0003061402350.95710-100000@iclub.nsu.ru>; from fjoe@iclub.nsu.ru on Mon, Mar 06, 2000 at 02:09:16PM %2B0600
References:  <20000306084031.A35426@cons.org> <Pine.BSF.4.21.0003061402350.95710-100000@iclub.nsu.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
In <Pine.BSF.4.21.0003061402350.95710-100000@iclub.nsu.ru>, Max Khon wrote: 
> hi, there!
> 
> On Mon, 6 Mar 2000, Martin Cracauer wrote:
> 
> > I just checked POSIX 1003.2.
> > 
> > for name [ in word ] 
> > do
> > 	compound-list
> > done
> > 
> > "First, the list of words following 'in' shall be expanded to generate
> > a list of items." [...] "If no items result from the expansion, the
> > compound-list shall not be executed."
> > 
> > <nothing> is not a word at all, so it can't be expanded, so I think
> > bash is corrent to complain about a syntax error.
> > 
> > It is clear, though, that your (John) example "variable expansion to
> > nothing" is not an error and both shells do it right.
> 
> A lot of stuff in /usr/ports/Mk/bsd.port.mk depends on current /bin/sh
> behaviour ("do nothing" instead of "complain and bail out").
> I am the original poster and faced this problem when tried to port FreeBSD
> Ports subsystem to Solaris and Linux.

Hm,
  for s in ${SUBDIR}; do

Well, the trick here is that ${SUBDIR} is expanded by make, not sh, so
sh can end up with nothing.

Max, I apologize, your point is valid and I commented without seeing
your original message.

OK, I think we should leave the non-word syntax as valid in FreeBSD,
since it makes the ports case more elegant and POSIX make it that
clear that sh must raise an error.

Max, I think the best way to port the ports subsystem is to take
FreeBSD's sh with you and point ${SH} to it, not the system's native
sh. Many native sh's have other things they do different from
FreeBSD's sh and bash (i.e. reaction on SIGINT, see
http://www.cons.org/cracauer/sigint.html), so I think this will
shorten your path considerably.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer/
  Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000306092322.A14710>