aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ash_test/ash-read/read_d0.right1
-rwxr-xr-xshell/ash_test/ash-read/read_d0.tests1
-rw-r--r--shell/hush_test/hush-read/read_d0.right1
-rwxr-xr-xshell/hush_test/hush-read/read_d0.tests1
-rw-r--r--shell/shell_common.c6
5 files changed, 9 insertions, 1 deletions
diff --git a/shell/ash_test/ash-read/read_d0.right b/shell/ash_test/ash-read/read_d0.right
new file mode 100644
index 000000000..9daeafb98
--- /dev/null
+++ b/shell/ash_test/ash-read/read_d0.right
@@ -0,0 +1 @@
test
diff --git a/shell/ash_test/ash-read/read_d0.tests b/shell/ash_test/ash-read/read_d0.tests
new file mode 100755
index 000000000..630d80787
--- /dev/null
+++ b/shell/ash_test/ash-read/read_d0.tests
@@ -0,0 +1 @@
printf 'test\0zest\n' | (read -d '' reply; echo "$reply")
diff --git a/shell/hush_test/hush-read/read_d0.right b/shell/hush_test/hush-read/read_d0.right
new file mode 100644
index 000000000..9daeafb98
--- /dev/null
+++ b/shell/hush_test/hush-read/read_d0.right
@@ -0,0 +1 @@
test
diff --git a/shell/hush_test/hush-read/read_d0.tests b/shell/hush_test/hush-read/read_d0.tests
new file mode 100755
index 000000000..630d80787
--- /dev/null
+++ b/shell/hush_test/hush-read/read_d0.tests
@@ -0,0 +1 @@
printf 'test\0zest\n' | (read -d '' reply; echo "$reply")
diff --git a/shell/shell_common.c b/shell/shell_common.c
index e50a79b78..a6ee60851 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -271,8 +271,10 @@ shell_builtin_read(struct builtin_read_params *params)
271#endif 271#endif
272 272
273 c = buffer[bufpos]; 273 c = buffer[bufpos];
274 if (c == '\0' || (ENABLE_PLATFORM_MINGW32 && c == '\r')) 274#if ENABLE_PLATFORM_MINGW32
275 if (c == '\r')
275 continue; 276 continue;
277#endif
276 if (!(read_flags & BUILTIN_READ_RAW)) { 278 if (!(read_flags & BUILTIN_READ_RAW)) {
277 if (backslash) { 279 if (backslash) {
278 backslash = 0; 280 backslash = 0;
@@ -287,6 +289,8 @@ shell_builtin_read(struct builtin_read_params *params)
287 } 289 }
288 if (c == delim) /* '\n' or -d CHAR */ 290 if (c == delim) /* '\n' or -d CHAR */
289 break; 291 break;
292 if (c == '\0')
293 continue;
290 294
291 /* $IFS splitting. NOT done if we run "read" 295 /* $IFS splitting. NOT done if we run "read"
292 * without variable names (bash compat). 296 * without variable names (bash compat).