aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/sed.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-02-12 21:38:34 -0800
committerRob Landley <rob@landley.net>2019-02-13 05:51:27 -0600
commitb928ec480cd73fd83511c0f5ca786d1b9f3167c3 (patch)
treef8bd1787339a9a5d6a39cc9ee7f02dc052548e30 /toys/posix/sed.c
parent7079a558d6e9448d5434965985b650c1e572140e (diff)
downloadtoybox-b928ec480cd73fd83511c0f5ca786d1b9f3167c3.tar.gz
sed: fix endless loop in "b loop" test.
Very few places actually check for errors from emit, and I actually see the same endless loop from "sed (GNU sed) 4.4" on current Debian, so I'm not sure this isn't Broken As Designed, but an endless loop spewing "short write" (or saying nothing, in the case of GNU sed) really doesn't feel like useful behavior in face of EPIPE, which really isn't going to fix itself. Certainly not being able to run the sed tests to completion is pretty annoying --- which is why, unless we remove this test as invalid, we should probably also add a SKIP_HOST=1 to the "b loop" test. Note that even with this fix you'll see the error twice: sed: short write: Broken pipe sed: short write: Broken pipe Once from the first = command to fail, and then another from the !FLAG(n) flush of the pattern space.
Diffstat (limited to 'toys/posix/sed.c')
-rw-r--r--toys/posix/sed.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/toys/posix/sed.c b/toys/posix/sed.c
index 0be2165e..5e516249 100644
--- a/toys/posix/sed.c
+++ b/toys/posix/sed.c
@@ -600,7 +600,7 @@ writenow:
}
} else if (c=='=') {
sprintf(toybuf, "%ld", TT.count);
- emit(toybuf, strlen(toybuf), 1);
+ if (emit(toybuf, strlen(toybuf), 1)) break;
}
command = command->next;