[Bug 270394] find(1): doesn't pass all files to the -exec utility

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 22 Mar 2023 04:48:47 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270394

Li-Wen Hsu <lwhsu@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lwhsu@FreeBSD.org

--- Comment #1 from Li-Wen Hsu <lwhsu@FreeBSD.org> ---
I think this could be "works as intended."

The shell command will receive the first file path as $0 and the reset will be
assigned to $@.

So if find(1) found three files as `x/a x/b x/c`, the shell command will
receive them as:

$0 = x/a
$@ = x/b x/c

And:

$ find x -type f -exec sh -c 'echo "files=$@"' {} +
files=x/c x/a

$ find x -type f -exec sh -c 'echo "files=$0"' {} +
files=x/b

$ find x -type f -exec sh -c 'echo "files=$0 $@"' {} +
files=x/b x/c x/a

The GNU find(1) has the same behavior.

-- 
You are receiving this mail because:
You are the assignee for the bug.