Skip to content

Conversation

@tmccombs
Copy link
Collaborator

@tmccombs tmccombs commented Oct 3, 2025

If you use --print0 with --exec, it will now print a \0 between each set
of commands run. That is, between the output for the commands run for
each found item.

Fixes: #1797

If you use --print0 with --exec, it will now print a \0 between each set
of commands run. That is, between the output for the commands run for
each found item.

Fixes: sharkdp#1797
@tmccombs tmccombs requested review from Copilot and tavianator October 3, 2025 07:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the issue where --print0 flag did not work properly with --exec commands. The fix ensures that when both flags are used together, a null character (\0) is printed between the output of each found entry's command execution.

Key changes:

  • Removed mutex-based output synchronization in favor of a simpler approach
  • Modified the output buffer to handle null separators directly
  • Added test coverage for the new --print0 with --exec functionality

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/walk.rs Simplified thread spawning by removing mutex parameter
src/exec/mod.rs Updated execute method to accept null_separator boolean instead of mutex
src/exec/job.rs Removed mutex parameter and passed config.null_separator to execute
src/exec/command.rs Refactored OutputBuffer to handle null separators and removed mutex dependency
tests/tests.rs Added test case for --print0 with --exec functionality
doc/fd.1 Updated documentation to explain --print0 behavior with --exec
CHANGELOG.md Added changelog entry for the bug fix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}
// While this lock is active, this thread will be the only thread allowed
// to write its outputs.
let _lock = self.output_permission.lock().unwrap();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this lock was redundant, since we are acquiring the lock for stdout anyway.

@tmccombs tmccombs merged commit 5558e40 into sharkdp:master Oct 26, 2025
18 checks passed
@tmccombs tmccombs deleted the exec-nuls branch October 26, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] --print0 and --exec does not include null byte

2 participants