Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

head: fails to leave remaining bytes of file available for subsequent commands #7028

Closed
jfinkels opened this issue Dec 29, 2024 · 3 comments · Fixed by #7253
Closed

head: fails to leave remaining bytes of file available for subsequent commands #7028

jfinkels opened this issue Dec 29, 2024 · 3 comments · Fixed by #7253
Labels

Comments

@jfinkels
Copy link
Collaborator

Environment: Ubuntu 20.04, uutils main branch (git commit dddbc17), GNU coreutils v9.5.218-7e5b6.

Steps to reproduce:

printf "a\nb\n" > f
(head -n1 >/dev/null; cat) < f

What happens now: uutils head outputs nothing.

What I expected to happen: GNU head outputs b\n, as expected.

Notes: this is causing a failure in the GNU test file tests/head/head-pos.sh.

We ran into a similar issue with dd here #3008 which was fixed by opening the file from its raw file descriptor here #4189. Maybe a similar solution can be applied to this issue?

@karlmcdowall
Copy link
Contributor

I'll take a look at this.

@karlmcdowall
Copy link
Contributor

Have some changes drafted for this, but wanna get the fix for this issue mainlined first since I need that fix to make all the cases in tests/head/head-pos.sh pass.

@karlmcdowall
Copy link
Contributor

I've put up draft changes here. Wanna get some more testing added before mainlining the fix though.

karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 5, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
@jfinkels jfinkels linked a pull request Feb 6, 2025 that will close this issue
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 7, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
sylvestre pushed a commit to karlmcdowall/coreutils that referenced this issue Feb 14, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 20, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 20, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 20, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
RenjiSann pushed a commit to karlmcdowall/coreutils that referenced this issue Feb 24, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 24, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 26, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 26, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
karlmcdowall added a commit to karlmcdowall/coreutils that referenced this issue Feb 28, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
sylvestre pushed a commit to sylvestre/coreutils that referenced this issue Mar 18, 2025
Fix issue uutils#7028
Head tool now ensures that stdin is set to the last character
that was output by the tool. This ensures that if any subsequent
tools are run from the same input stream they will start at the
correct point in the stream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants