From owner-freebsd-bugs Tue May 12 11:53:32 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA00675 for freebsd-bugs-outgoing; Tue, 12 May 1998 11:53:32 -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 LAA00669 for ; Tue, 12 May 1998 11:53:31 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id LAA26222; Tue, 12 May 1998 11:50:00 -0700 (PDT) Date: Tue, 12 May 1998 11:50:00 -0700 (PDT) Message-Id: <199805121850.LAA26222@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.ORG From: Tor Egge Subject: Re: bin/6557: /bin/sh && IFS Reply-To: Tor Egge 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: Tor Egge To: dima@best.net Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: bin/6557: /bin/sh && IFS Date: Tue, 12 May 1998 20:46:16 +0200 > Try to run this script: > > #!/bin/sh > XXX=/1:/2:/3: > IFS=: > echo /0:$XXX > > The expected result should be: "/0 /1 /2 /3" > However, with current /bin/sh it's: "/0:/1 /2 /3" According to "X/Open Commands and Utilities Issue 4, Version 2" Section 2.6 "Word Expansion", field splitting is performed on the portions of the fields generated by tilde expansion, parameter expansion, command substitution and arithmetic expansion. i.e. your echo /0:$XXX should give Before Word Expansion: /0:$XXX after tilde expansion, parameter expansiion, command substitition and arithmetic expansion: /0:/1:/2:/3: ^^^^^^^^^ This is the portion of the field being the result of expansion. Any field splitting should only be performed on this portion. after field splitting: /0:/1 /2 /3 after pathname expansion: /0:/1 /2 /3 after quote removal: /0:/1 /2 /3 Correct field splitting results in 4 fields. `/0:/1' `/2' `3' `' The last (empty) field should not be removed, since it is not the complete expansion appropriate for a word (the word being `/0:$XXX' (without quotes)). ksh93 gives almost the same result as our /bin/sh (for this example). Unfortunately, it incorrectly removes the last field. bash incorrectly performs field splitting on portions of the fields that are not the result of expansion or substitution. bash also incorrectly removes the last field. - Tor Egge To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message