From owner-freebsd-bugs Sat Feb 22 15:50:09 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id PAA01203 for bugs-outgoing; Sat, 22 Feb 1997 15:50:09 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id PAA01193; Sat, 22 Feb 1997 15:50:04 -0800 (PST) Resent-Date: Sat, 22 Feb 1997 15:50:04 -0800 (PST) Resent-Message-Id: <199702222350.PAA01193@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, Scott.Blachowicz@seaslug.org Received: from one.sabami.seaslug.org (sail.statsci.com [206.63.206.1]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id PAA00911 for ; Sat, 22 Feb 1997 15:46:19 -0800 (PST) Received: (from scott@localhost) by one.sabami.seaslug.org (8.7.5/8.7.3) id PAA14709; Sat, 22 Feb 1997 15:44:08 -0800 (PST) Message-Id: <199702222344.PAA14709@one.sabami.seaslug.org> Date: Sat, 22 Feb 1997 15:44:08 -0800 (PST) From: Scott Blachowicz Reply-To: Scott.Blachowicz@seaslug.org To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/2803: /bin/sh 'for' statement vs IFS setting problem Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 2803 >Category: bin >Synopsis: /bin/sh 'for' doesn't token break properly >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Feb 22 15:50:02 PST 1997 >Last-Modified: >Originator: Scott Blachowicz >Organization: none >Release: FreeBSD 2.1.5-RELEASE >Environment: FreeBSD one.sabami.seaslug.org 2.1.5-RELEASE FreeBSD 2.1.5-RELEASE #0: Thu Sep 26 21:57:44 PDT 1996 root@one.sabami.seaslug.org:/usr/src-CD/sys/compile/SABAMI i386 >Description: It APPEARS as if the IFS characters in the list of tokens to loop over get replaced by blanks after it has already been broken up into tokens instead of before the tokenizing. I ran across this using an autoconf generated configure script (trying to locate a program along a colon-separated list of directory names), so I imagine that others will stumble across this. >How-To-Repeat: I use this test script: #! /bin/sh IFS=' :' for tok in a:b:c do echo $tok done for tok in d e f do echo $tok done which SHOULD output 6 lines of output (letters a-f on separate lines), but what comes out is this: a b c d e f >Fix: 1) filter the list of tokens thru sed to replace the :'s with blanks: for tok in `echo a:b:c | sed 's/:/ /'` do echo $tok done 2) throw an extra "eval" in there: for tok in `eval echo a:b:c` do echo $tok done >Audit-Trail: >Unformatted: