Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jul 1998 12:10:01 -0700 (PDT)
From:      Tor.Egge@fast.no
To:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: bin/7154: IFS Not working right
Message-ID:  <199807031910.MAA01695@freefall.freebsd.org>

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

From: Tor.Egge@fast.no
To: zerium@webindex.no
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/7154: IFS Not working right
Date: Fri, 03 Jul 1998 21:06:09 +0200

 > $ IFS=":" ls:/
 > ls:/: not found
 > $ IFS=":" for i in df:df; do echo $i; done
 > df df
 > (no newline)
 
 This is correct behavior and not a bug in sh.
 
 According to "X/Open Commands and Utilities Issue 4, Version 2", field
 splitting should only be performed on the portions of the fields
 generated by tilde expansion, parameter expansion, command
 substitution and arithmetic expansion.
 
 /bin/sh on SunOS performs field splitting on all fields, resulting in
 potential security problems.
 
 bash performs field splitting on the complete field if a part of the
 field is the result of expansion/substitition.
 
 Using bash and performing the command
 
 	( IFS=":" ; echo abc:def$ghi abc:def\$ghi )
 
 gives
 	abc def abc:def$ghi
 
 resulting in the backslash effectively quoting the ':' character
 in addition to the expected quoting of the following '$' character.
 
 Bash also has a tendency to remove quoted empty fields and
 introduce garbage characters in the expansion of $@.
 
 	#!/usr/local/bin/bash
 	A=
 	set -- ''$A
 	echo $#
 	A=" "
 	set -- ''$A
 	echo $#
 	IFS=
 	set "" abc "def ghi" "" jkl ""
 	echo "xx$@$@yy"
 
 results in some DEL (0x7f) characters being printed when using bash:
 
 	1
 	0
 	xx abc def ghi  jkl  abc def ghi  jkl yy
 
 The correct result is
 
 	1
 	1
 	xx abc def ghi  jkl  abc def ghi  jkl yy
 
 In my opinion, the definitions of AC_CHECK_PROG and AC_PATH_PROG in
 autoconf (acgeneral.m4) should be changed to handle shells that
 perform field splitting differently from bash.
 
 - 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?199807031910.MAA01695>