On 08/02/2026 07:10, Collin Funk wrote:
Hi Sam,
Sam James <[email protected]> writes:
(originally reported downstream at https://bugs.gentoo.org/969663)
I see
FAIL: tests/misc/read-errors.sh
on a system with /bin/sh provided by dash rather than bash.
The error messages from dash are different:
/var/tmp/portage/sys-apps/coreutils-9.10/work/coreutils-9.10 # strace -o /dev/null
-P /dev/null -e /read,splice -e fault=all:error=EIO /bin/sh -c read < /dev/null
/bin/sh: 1: read: arg count
/var/tmp/portage/sys-apps/coreutils-9.10/work/coreutils-9.10 # strace -o /dev/null
-P /dev/null -e /read,splice -e fault=all:error=EIO /bin/bash -c read <
/dev/null
/bin/bash: line 1: read: 0: read error: Input/output error
Full read-errors.log at
https://bugs.gentoo.org/attachment.cgi?id=954718.
Thanks for the report.
It looks like 'read' without a variable is a Bash extension, which
stores the result in $REPLY [1]. POSIX's SYNOPSIS makes it look like at
least one variable is required [2].
One would think the easy fix is to add a variable to the
invocation. However, 'dash' annoyingly does not print any error message
upon read(2) failing:
$ strace -P /dev/null -e '/read,splice' -e fault=all:error=EIO bash -c 'read
a < /dev/null'
read(0, 0x559c9691f9e0, 4096) = -1 EIO (Input/output error)
(INJECTED)
bash: line 1: read: 0: read error: Input/output error
$ strace -P /dev/null -e '/read,splice' -e fault=all:error=EIO dash -c 'read
a < /dev/null'
read(0, 0x7ffe7bde0aef, 1) = -1 EIO (Input/output error)
(INJECTED)
+++ exited with 1 +++
I'll have to think a bit more for a fix. Ideally this test shouldn't
depend on bash or some other program.
Collin
[1]
https://www.gnu.org/software/bash/manual/bash.html#Major-Differences-From-The-Bourne-Shell-1
[2] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/read.html
TIL $REPLY is a bashism.
Drats I tested with `make SHELL=/bin/dash ...` when I
should have tested with `make PREFERABLY_POSIX_SHELL=/bin/dash ...`
Sam, the quickest fix for you is to use bash or skip,
which is done in the attached.
The best long term fix for us is to use getsys
to get the appropriate error text, as I detailed at:
https://lists.gnu.org/archive/html/coreutils/2026-01/msg00187.html
We've lots of hacks in the test suite re error messages,
which this is just another. I'll work on this now.
BTW it's interesting that both dash and ksh do _not_ diagnose EIO.
Looks like a bug to me:
$ /bin/dash -c 'read foo < /proc/self/mem'
$ /bin/ksh -c 'read foo < /proc/self/mem'
thanks,
Padraig
diff --git a/tests/misc/read-errors.sh b/tests/misc/read-errors.sh
index c05516505..1e2bd6f02 100755
--- a/tests/misc/read-errors.sh
+++ b/tests/misc/read-errors.sh
@@ -17,6 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+require_bash_as_SHELL_
uses_strace_
! cat . >/dev/null 2>&1 || skip_ "Need unreadable directories"