Bug 218057 - bash fails to redirect
Summary: bash fails to redirect
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.0-STABLE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-24 06:38 UTC by Kazuma TAKAOKA
Modified: 2017-03-25 23:19 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazuma TAKAOKA 2017-03-24 06:38:52 UTC
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.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2017-03-24 14:13:18 UTC
Notify committer of r315854.  The commits are a little bit confusing for me.
Comment 2 Andriy Gapon freebsd_committer freebsd_triage 2017-03-24 15:09:55 UTC
(In reply to Mark Linimon from comment #1)
Eh?
Comment 3 Mateusz Guzik freebsd_committer freebsd_triage 2017-03-24 15:42:29 UTC
can you please test after updating to r315895?
Comment 4 Kazuma TAKAOKA 2017-03-25 04:44:11 UTC
(In reply to Mateusz Guzik from comment #3)
It works well.
Thanks.
Comment 5 Mateusz Guzik freebsd_committer freebsd_triage 2017-03-25 23:19:19 UTC
Thanks for testing.

For book keeping purposes fixed in https://svnweb.freebsd.org/changeset/base/315895