From owner-freebsd-bugs Tue May 12 13:13:39 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA15467 for freebsd-bugs-outgoing; Tue, 12 May 1998 13:13:39 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA15454 for ; Tue, 12 May 1998 13:13:35 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id NAA26561; Tue, 12 May 1998 13:10:04 -0700 (PDT) Date: Tue, 12 May 1998 13:10:04 -0700 (PDT) Message-Id: <199805122010.NAA26561@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.ORG From: woods@zeus.leitch.com (Greg A. Woods) Subject: Re: bin/6557: /bin/sh && IFS Reply-To: woods@zeus.leitch.com (Greg A. Woods) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/6557; it has been noted by GNATS. From: woods@zeus.leitch.com (Greg A. Woods) To: Martin Cracauer Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: bin/6557: /bin/sh && IFS Date: Tue, 12 May 1998 16:07:30 -0400 (EDT) [ On Tue, May 12, 1998 at 08:20:01 (-0700), Martin Cracauer wrote: ] > Subject: Re: bin/6557: /bin/sh && IFS > > However, it is my current opinion that my fix and bash are > wrong. Hence I didn't commit it although you are invited to see if it > fits your needs, it's in the url given above. It would seem Bash agrees with the real Korn Shell and the real Bourne Shell. I agree with them too. > I still don't have a POSIX reference, but I've been told that POSIX > specifies that word splitting is to be done during evaluation, not > during parsing. I think it's obvious that IFS split is part of word > splitting. This is the relavent section from POSIX 1003.2 Draft 11.2: (the Open Group's "Single UNIX Specification" says essentially the same things too...) Copyright c 1991 IEEE. All rights reserved. This is an unapproved IEEE Standards Draft, subject to change. Part 2: SHELL AND UTILITIES P1003.2/D11.2 . . . 3.6.5 Field Splitting After parameter expansion (3.6.2), command substitution (3.6.3), and arithmetic expansion (3.6.4) the shell shall scan the results of expansions and substitutions that did not occur in double-quotes for field splitting and multiple fields can result. The shell shall treat each character of the IFS as a delimiter and use the delimiters to split the results of parameter expansion and command substitution into fields. (1) If the value of IFS is , , and , or if it is unset, any sequence of , , or characters at the beginning or end of the input shall be ignored and any sequence of those characters within the input shall delimit a field. (For example, the input foobar yields two fields, foo and bar). (2) If the value of IFS is null, no field splitting shall be performed. (3) Otherwise, the following rules shall be applied in sequence. 1 The term ``IFS white space'' is used to mean any sequence (zero 1 or more instances) of white-space characters that are in the IFS 1 value (e.g., if IFS contains , any sequence 1 of and characters is considered IFS white space). 1 (a) IFS white space shall be ignored at the beginning and end 1 of the input. 1 (b) Each occurrence in the input of an IFS character that is 1 not IFS white space, along with any adjacent IFS white 1 space, shall delimit a field, as described previously. 1 (c) Nonzero-length IFS white space shall delimit a field. 1 BEGIN_RATIONALE 3.6.5.1 Field Splitting Rationale. (This subclause is not a part of P1003.2) The operation of field splitting using IFS as described in earlier drafts was based on the way the KornShell splits words, but is incompatible with other common versions of the shell. However, each has merit, and so a decision was made to allow both. If the IFS variable is unset, or is , the operation is equivalent to the way the System V shell splits words. Using characters outside the set yields the KornShell behavior, where each of the non- characters is significant. This behavior, which affords the most flexibility, was taken from the way the original awk handled field splitting. The (3) rule can be summarized as a pseudo ERE: 1 (s*ns*|s+) 1 where s is an IFS white-space character and n is a character in the IFS 1 that is not white space. Any string matching that ERE delimits a field, 1 except that the s+ form does not delimit fields at the beginning or the 1 end of a line. For example, if IFS is , the string 1 red,whiteblue 1 yields the three colors as the delimited fields. 1 END_RATIONALE -- Greg A. Woods +1 416 443-1734 VE3TCP Planix, Inc. ; Secrets of the Weird To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message