Suspecting bug in /bin/sh's IFS

Stefan Farfeleder stefan at fafoe.narf.at
Sun Mar 22 15:32:03 PDT 2009


On Sat, Mar 21, 2009 at 10:46:34PM +0100, Jilles Tjoelker wrote:
> 
> The code is wrong, but your patched code is also wrong. The read builtin
> should use the same logic as normal field splitting, with additional
> rules if there are more fields in the input than variables.
> 
> I have noticed that NetBSD has already fixed this. I have ported these
> fixes over: http://www.stack.nl/~jilles/unix/sh-read-split.patch
> The patch is against RELENG_7, I hope it applies to -CURRENT as well.
> 
> The NetBSD commit message also refers to
> http://www.research.att.com/~gsf/public/ifs.sh
> Just like their /bin/sh, our /bin/sh with the patch now passes the
> 'read' tests from there (there are still many other failures though).
> 
> By the way, to avoid all processing by read, one must IFS= read -r VAR.
> Without the IFS specification, leading and trailing whitespace will
> still be stripped.

Thank you, I have committed this patch.


More information about the freebsd-standards mailing list