Bash fails to redirect on recent 11.0-STABLE. It seems to be caused by r315312 (MFC r305093). $ uname -a FreeBSD krsna 11.0-STABLE FreeBSD 11.0-STABLE #10 r315854: Thu Mar 23 19:43:16 JST 2017 root@krsna:/usr/obj/usr/src/sys/GENERIC amd64 $ bash --version GNU bash, version 4.4.12(1)-release (amd64-portbld-freebsd11.0) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. $ cat test.sh echo a 3<&2 $ bash test.sh test.sh: redirection error: cannot duplicate fd: Bad file descriptor test.sh: line 1: 2: Bad file descriptor r315854: $ truss /usr/local/bin/bash test.sh ... read(255,"echo a 3<&2\n",12) = 12 (0xc) fcntl(3,F_GETFD,) = 0 (0x0) fcntl(3,F_DUPFD,0xa) ERR#9 'Bad file descriptor' fcntl(3,F_DUPFD,0xa) ERR#9 'Bad file descriptor' fcntl(3,F_DUPFD,0x0) ERR#9 'Bad file descriptor' ... r306420: $ truss /usr/local/bin/bash test.sh ... read(255,"echo a 3<&2\n",12) = 12 (0xc) fcntl(3,F_GETFD,) ERR#9 'Bad file descriptor' dup2(0x2,0x3) = 3 (0x3) fcntl(2,F_GETFD,) = 0 (0x0) a write(1,"a\n",2) = 2 (0x2) close(3) = 0 (0x0) ... I removed r305093 and it worked.
Notify committer of r315854. The commits are a little bit confusing for me.
(In reply to Mark Linimon from comment #1) Eh?
can you please test after updating to r315895?
(In reply to Mateusz Guzik from comment #3) It works well. Thanks.
Thanks for testing. For book keeping purposes fixed in https://svnweb.freebsd.org/changeset/base/315895