From d08381bc261d95502a205f7214686f80383c9692 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 31 Mar 2014 10:21:58 -0700 Subject: head: fix bug with head -c-N when stdin is not at start * src/head.c (elide_tail_bytes_file): Fix typo in lseek invocation. * tests/misc/head-c.sh: Add test for this bug. * NEWS: Document this. --- src/head.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/head.c') diff --git a/src/head.c b/src/head.c index b833af675..e27ce4618 100644 --- a/src/head.c +++ b/src/head.c @@ -443,7 +443,7 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide) /* Seek back to 'current' position, then copy the required number of bytes from fd. */ - if (lseek (fd, 0, current_pos) == -1) + if (lseek (fd, current_pos, SEEK_SET) < 0) { error (0, errno, _("%s: cannot lseek back to original position"), quote (filename)); -- cgit v1.2.3-54-g00ecf