Repository navigation
Conversation
Piped stdin comes first, and a header with the file name comes before each file when there is more than one input. -F and -P still pick the first line written.
Read errors are still reported per input, including piped stdin, and the next input is shown. Add a CannotRead error and share the header rule with the pager.
musl says "I/O error" where glibc says "Input/output error", so build the expected message from the platform's strerror.
Searching for the pattern kept every line read, so a file without a match ended up in memory. Hold one line at a time and seek back to where the search started; a FIFO can't seek, so nothing is shown. Report stdin read errors with MoreError::CannotRead like files.
When stdout isn't a terminal, write every input unchanged, the way less does, so the output can be used as data. The start line and pattern still apply when paging.
…ttern" This reverts commit 1f1553d. util-linux applies the start line and pattern to piped output too, and compatibility with it comes first.
When output isn't a terminal, print "Pattern not found" on its own line before the file, like the pager does. The start line and pattern now only apply to the first input, even one that can't be opened.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Piped output is part of the contract, so match util-linux byte for byte: no newline after the message, and three spaces before a header.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
With
-Pand no matching line,morepiped to a file or pipe wrote the file silently, while util-linux printsPattern not foundfirst. Also, every file was searched for the pattern instead of only the first input.Now
Pattern not foundis printed before the file, byte for byte as util-linux does: no newline, and three spaces before a header. The start line and pattern apply only to the first input, even one that can't be opened, and piped stdin uses them up as the first input.Depends on #16944.
Part of #16940