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

docs: Explicitly warn against relying on result order for exec #1405

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/fd.1
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ This option can be specified multiple times, in which case all commands are run
file found, in the order they are provided. In that case, you must supply a ';' argument for
all but the last commands.

If parallelism is enabled, the order commands will be exectued in is non-deterministic. And even with
--threads=1, the order is determined by the operating system and may not be what you expect. Thus, it is
recommended that you don't rely on any ordering of the results.

The following placeholders are substituted before the command is executed:
.RS
.IP {}
Expand Down Expand Up @@ -411,6 +415,9 @@ Examples:
Execute
.I command
once, with all search results as arguments.

The order of the arguments is non-deterministic and should not be relied upon.

One of the following placeholders is substituted before the command is executed:
.RS
.IP {}
Expand Down
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ impl clap::Args for Exec {
.help("Execute a command for each search result")
.long_help(
"Execute a command for each search result in parallel (use --threads=1 for sequential command execution). \
There is no guarantee of the order commands are executed in, and the order should not be depended upon. \
All positional arguments following --exec are considered to be arguments to the command - not to fd. \
It is therefore recommended to place the '-x'/'--exec' option last.\n\
The following placeholders are substituted before the command is executed:\n \
Expand Down Expand Up @@ -834,6 +835,7 @@ impl clap::Args for Exec {
.help("Execute a command with all search results at once")
.long_help(
"Execute the given command once, with all search results as arguments.\n\
The order of the arguments is non-deterministic, and should not be relied upon.\n\
One of the following placeholders is substituted before the command is executed:\n \
'{}': path (of all search results)\n \
'{/}': basename\n \
Expand Down