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

Re: Tightening up specification of /bin/sh



> On 21-May-01, 05:22 (CDT), Patrik Hagglund <patha@softlab.ericsson.se> wrote: 
> > I don't see what you mean by "the initial value of the IFS
> > variable". Is there anything that is unspecified for field
> > splitting in IEEE Std. 1003.2-1992? Isn't "If IFS is not set, the
> > shell shall behave as if the value of IFS were the <space>, <tab>,
> > and <newline> characters." (page 123) enough?

Zack Weinberg wrote:
> This misses the point.  The phrase being quoted here is _not_ from
> 1003.2-1992, it's from the XPG/4 webpage describing the shell.  It may
> also be in 1003.2-1992 but can anyone prove that? 

The quote _is_ from the POSIX standard (I have the ISO version
ISO/IEC 9945).

> It's my contention that nearly no one has access to the genuine
> standard or even a reliable source describing the genuine
> standard. 
> 
> That being so, the only way to determine what is or is
> not portable shell is to test a putatively portable feature on
> many different shells.

Hmm.. You now seems to prefer a number of implementations as the
_primary_ reference, rather than a secondary reference point as
stated previously.

SUSv2 is available at
http://www.unix-systems.org/single_unix_specification_v2/. The
current POSIX draft (which supersedes SUSv2, and, as mentioned
previously, will soon replace the current POSIX standard) is
available at http://www.opengroup.org/austin/.

> I for one feel comfortable
> arguing that if five different shells all do something the same way -
> e.g. they all set IFS to <space><tab><newline> on startup, ignoring
> any value in the environment

The problem is that in this case they don't do it the same way.

According to POSIX they shouldn't ignore the value in the
environment. At least ash seems to get this right:

  > BAR=bar IFS=a ash -c 'echo_args ${BAR} "b${IFS}r"'
  arg #1: b$
  arg #2: r$
  arg #3: bar$

with echo_args implemented as

  include <stdio.h>
  
  int main(int argc, char **argv) {
     int i;
     for (i = 1; i < argc; i++) {
         printf("arg #%d: %s$\n", i, argv[i]);
     }
     return 0;
  }  

For reference, this is the output from bash:

  > BAR=bar IFS=a bash -c 'echo_args ${BAR} "b${IFS}r"'
  arg #1: bar$
  arg #2: b 	
  r$
  
My conclusion remains, trying to refer to a consensus - current
implementation practice - that doesn't exist isn't useful.

--
Patrik Hägglund



Reply to: