When I go

    read -d '' VAR

it doesn't accept the line of input when I type the NUL byte (variously ^@,
^`, or ctrl-space depending on the keyboard).

It turns out that's because  _POSIX_VDISABLE is '\0' on my system; I
suspect that's typical, though I have seen systems where it's '\xff'.

So when delim is _POSIX_VDISABLE, simply switch back to the old method:

diff --git a/builtins/read.def b/builtins/read.def
index 70e08126d..c939e991e 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -627,7 +627,7 @@ read_builtin (WORD_LIST *list)

          ttset = ttattrs;
+
+         #ifdef _POSIX_VDISABLE
+         const int vdis = _POSIX_VDISABLE;
+         #else
+         const int vdis = pathconf("/dev/tty", _PC_VDISABLE);
+         #endif

-         if (nchars > 0)
+         if (nchars > 0 || delim == vdis)
            rc = silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd,
&ttset);
-         else          /* delim != '\n' */
+         else          /* delim ∉ {'\n', _POSIX_VDISABLE} */
            {

-Martin

Reply via email to