[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11631: Head command does not position file pointer correctly for neg
From: |
Anoop Sharma |
Subject: |
bug#11631: Head command does not position file pointer correctly for negative line count |
Date: |
Tue, 5 Jun 2012 15:07:19 +0530 |
Head command does not position file pointer correctly for negative line
count. Here is a demonstration of the problem.
Step 1 - Create a file with 10 lines in it.
$ yes "ABC" | head -c 40 >ip.txt
$
Step 2 - If head behaves correctly, then 2 lines should get printed after
"------------" but nothing gets printed!
$ (head -n -2; echo "------------------------"; cat) <ip.txt
ABC
ABC
ABC
ABC
ABC
ABC
ABC
ABC
------------------------
$
Step 3 - Another try fails. If head behaves correctly, then 8 lines should
get printed after "------------" but nothing gets printed!
$ (head -n -8; echo "------------------------"; cat) <ip.txt
ABC
ABC
------------------------
$
/*****************************************************************************************************************************/
Possible cause of the defect -> Following snippet is copied from head.c
(Function - elide_tail_lines_seekable ). Perhaps, there should be a lseek
after fwrite there...:
/* Output the initial portion of the buffer
in which we found the desired newline byte.
Don't bother testing for failure for such a small amount.
Any failure will be detected upon close. */
fwrite (buffer, 1, n + 1, stdout);
/*****************************************************************************************************************************/
- bug#11631: Head command does not position file pointer correctly for negative line count,
Anoop Sharma <=
- bug#11631: Head command does not position file pointer correctly for negative line count, Voelker, Bernhard, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- Message not available
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Pádraig Brady, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
Message not available