GNU bug report logs -
#75197
[Feature Request] Support 'grep -A' without number to show all lines after match
Previous Next
Full log
View this message in rfc822 format
Or, for us old farts who have been using 'sed' for a half century, if I wanted to print the lines in a file starting with the line matching a certain pattern, through the remaining lines of the file, I'd use:
sed -n '/pattern/,$/p' < file
Then I wouldn't have to worry whether or not the 'grep' command I was using would lose it's lunch trying to parse '9999999999999999999999', though, granted, every executable 'grep' binary I happen to have on my disk, a couple dozen of them going back over 20 years, all handle the forty-nine 9's I just tested, HOWEVER the busybox 0.51 grep source code circa 2001 I have at hand will fail if strtoul of the numeric argument to "-A" overflows, returning ULONG_MAX with errno of ERANGE, and likely some older variants of grep would also fail, _and_
I wouldn't have to worry that my 'magic' number wasn't big enough for every ordinary, already written to disk, file that I might be reading, _and_
I could run this off a pipe that never ended with a normal closure of the input stream that would have sent an EOF to input stream of 'sed', but only ended with a signal or hardware stoppage, without worrying that I had not put enough nine's (9) in my number, _and_
I wouldn't have readers of that code wondering what that strange number was ... though, granted, I would have them doing 'man sed' ... about time in my book.
But, yes, as Paul Eggert notes, command line parsing of 'grep -A 123' would be ambiguous. Is "123" a filename, or a parameter to the "-A" argument?
--
Paul Jackson
jackson <at> fastmail.fm
This bug report was last modified 166 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.