From abd757eac42f9c5bb3f32f01d2928af05d3df3e0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 23 Jun 2000 09:45:38 +0000 Subject: 12044: read -A bug --- Src/builtin.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Src') diff --git a/Src/builtin.c b/Src/builtin.c index 90c82c06e..69dcdd70f 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3553,6 +3553,15 @@ bin_read(char *name, char **args, char *ops, int func) } if (c == EOF || c == '\n') break; + /* + * `first' is non-zero if any separator we encounter is a + * non-whitespace separator, which means that anything + * (even an empty string) between, before or after separators + * is significant. If it is zero, we have a whitespace + * separator, which shouldn't cause extra empty strings to + * be emitted. Hence the test for (*buf || first) when + * we assign the result of reading a word. + */ if (!bslash && isep(c)) { if (bptr != buf || (!iwsep(c) && first)) { first |= !iwsep(c); @@ -3587,7 +3596,7 @@ bin_read(char *name, char **args, char *ops, int func) zputs(buf, stdout); putchar('\n'); } - if (!ops['e']) { + if (!ops['e'] && (*buf || first)) { if (ops['A']) { addlinknode(readll, buf); al++; -- cgit 1.4.1