From owner-freebsd-bugs Fri Jul 3 12:11:25 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA07400 for freebsd-bugs-outgoing; Fri, 3 Jul 1998 12:11:25 -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 MAA07395 for ; Fri, 3 Jul 1998 12:11:24 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id MAA01695; Fri, 3 Jul 1998 12:10:01 -0700 (PDT) Date: Fri, 3 Jul 1998 12:10:01 -0700 (PDT) Message-Id: <199807031910.MAA01695@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.ORG From: Tor.Egge@fast.no Subject: Re: bin/7154: IFS Not working right Reply-To: Tor.Egge@fast.no Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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