Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 May 1998 11:50:00 -0700 (PDT)
From:      Tor Egge <Tor.Egge@idi.ntnu.no>
To:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: bin/6557: /bin/sh && IFS
Message-ID:  <199805121850.LAA26222@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/6557; it has been noted by GNATS.

From: Tor Egge <Tor.Egge@idi.ntnu.no>
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



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