Bug 84000 - for-statement expansion with IFS changed broken
for-statement expansion with IFS changed broken
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
8.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-02-10 16:37 EST by Robert K. Moniot
Modified: 2007-04-18 12:50 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-02-25 09:16:45 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Robert K. Moniot 2003-02-10 16:37:57 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021120
Netscape/7.01

Description of problem:
The expansion of the list of a for statement does not work the same with IFS
changed as it does with the default IFS.  If the list consists of a variable
containing a list of items separated by IFS, and this variable is followed by
IFS and then another item, the last item in the variable's list is concatenated
with the following item.  This does not happen when IFS is blank space.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Run the script provided below.
2.
3.
    

Actual Results:  foo
bar
baz
next
foo
bar
baz next


Expected Results:  foo
bar
baz
next
foo
bar
baz
next


Additional info:
Here's the script that shows it

#! /bin/sh
TO_DO_LIST="foo bar baz"
for item in $TO_DO_LIST next
do
  echo $item
done

IFS=:
TO_DO_LIST="foo:bar:baz"
for item in $TO_DO_LIST:next
do
  echo $item
done
Comment 1 Tim Waugh 2003-02-25 09:16:45 EST
Upstream maintainer clarified the issue to me in private mail: only the result
of the variable expansion is eligible for field splitting here.  Use 'echo
"$item"' to see more clearly what's going on; you get this output:

bar
baz
next
foo
bar
baz:next

This is how POSIX specifies field splitting to operate.

Note You need to log in before you can comment on or make changes to this bug.