pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/51142: pdksh has occasional issues with empty 'for' loops



The following reply was made to PR pkg/51142; it has been noted by GNATS.

From: Joerg Sonnenberger <joerg%bec.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: pkg-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, pkgsrc-bugs%netbsd.org@localhost,
	richard%NetBSD.org@localhost
Subject: Re: pkg/51142: pdksh has occasional issues with empty 'for' loops
Date: Mon, 16 May 2016 10:58:26 +0200

 On Mon, May 16, 2016 at 04:55:01AM +0000, Richard PALO wrote:
 > The following reply was made to PR pkg/51142; it has been noted by GNATS.
 > 
 > From: Richard PALO <richard%netbsd.org@localhost>
 > To: gnats-bugs%NetBSD.org@localhost
 > Cc: 
 > Subject: Re: pkg/51142: pdksh has occasional issues with empty 'for' loops
 > Date: Mon, 16 May 2016 06:52:36 +0200
 > 
 >  Le 15/05/16 19:30, Joerg Sonnenberger a écrit :
 >  >  That's not a shell bug, but a "feature" of the standard. A common
 >  >  pattern found e.g. in mk/ is to explicit append '' (empty string) and
 >  >  short cut with [ -n "$i" ] || break
 >  >  
 >  >  Joerg
 >  
 >  Indeed! 
 >  http://pubs.opengroup.org/onlinepubs/009604499/utilities/xcu_chap02.html#tag_02_14
 >  does say:
 >  > The format for the for loop is as follows:
 >  > 
 >  >     for name [ in [word ... ]]do
 >  >         compound-list
 >  > 
 >  > 
 >  >     done
 
 Actually, you are looking at a too-new version. Try SUSv2 for example:
 http://pubs.opengroup.org/onlinepubs/7908799/xcu/chap2.html#tag_001_009_004_002
 
     for name [ in word ... ]
     do
         compound-list
     done
 
 ...and that has been interpreted historically by some shells (this one
 included) to mean that after the "in" something must be found. The BNF
 grammar is similar problematic. I'm not really objecting to fixing this
 is pdksh, but be careful to call it a bug.
 
 Joerg
 


Home | Main Index | Thread Index | Old Index