bin/173642: ``here-document'' does not works in FreeBSD 9 /bin/sh
jilles at stack.nl
Sat Nov 17 23:00:01 UTC 2012
The following reply was made to PR bin/173642; it has been noted by GNATS.
From: Jilles Tjoelker <jilles at stack.nl>
To: bug-followup at FreeBSD.org, Aleksandr A Babaylov <"."@babolo.ru>
Subject: bin/173642: ``here-document'' does not works in FreeBSD 9 /bin/sh
Date: Sat, 17 Nov 2012 23:51:54 +0100
In PR bin/173642:
> As of FreeBSD 9.0, the below script fails (with fdescfs mounted):
> cat /dev/fd/5
This script took advantage of a bug in sh that has been fixed. A
redirection should only apply for the duration of the command it is
attached to, except if that command is the builtin "exec". This includes
commands consisting solely of redirections (here-documents or other
kinds). Before 9.0, sh did not handle this properly if the fd was not
open before a redirection attached to some kinds of commands.
Note that the script will not work even with the older sh if fd 5 is
already open, for example
sh your-script 5</dev/null
The fix is to replace the line
This will also work with the older sh, fixing the problems if fd 5 is
I do not plan to merge the bugfix in sh to stable/8.
More information about the freebsd-bugs