[Bug 193759] Wrong behaviour of IFS='|' set in /bin/sh

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Sep 18 21:37:04 UTC 2014


Jilles Tjoelker <jilles at FreeBSD.org> changed:

           What    |Removed                     |Added
             Status|Needs Triage                |Issue Resolved
                 CC|                            |jilles at FreeBSD.org
         Resolution|---                         |Works As Intended
           Assignee|freebsd-bugs at FreeBSD.org    |jilles at FreeBSD.org

--- Comment #1 from Jilles Tjoelker <jilles at FreeBSD.org> ---
Thanks for your report. However, the behaviour is as designed and matches the
POSIX.1-2008 standard.

Firstly, assignments are performed after the command is expanded. Therefore, an
IFS= assignment preceding a command never affects word splitting of that
command itself.

Secondly, an assignment preceding a special built-in utility such as 'set'
remains in effect after the command completes. This explains why the second and
later commands work.

You need to set IFS before word splitting and possibly restore it later, or use
IFS=... read ... (where the assignment does affect read's splitting and does
not persist after the command completes).

You are receiving this mail because:
You are the assignee for the bug.

More information about the freebsd-bugs mailing list