tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: find -exec ... +
On Tue, 21 Dec 2010, David Holland wrote:
> So, according to the man page, in find -exec ... +, the {} is supposed
> to come only immediately before the +. That is, you can do
>
> % find foo -exec ls -l {} +
>
> but not
>
> % find foo -exec mv {} subdir/ +
Right. See
<http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-210.html>
for the rationale:
" Note that the "+" is only treated as special if it immediately
" follows "{}". This minimises the chances of causing problems with
" existing uses of "+" as an argument with "-exec".
Note "minimises", not "eliminates", problems with the use of "+"
inside a command used with "-exec ... \;".
> our find has a bug so it doesn't enforce this, so it breaks anyway:
We should fix that.
> I'm wondering if it wouldn't be more generally useful to make it
> accept these cases and do the substitution in the correct word. I
> haven't actually implemented this yet but I don't see any particular
> barrier to doing so. Alternatively we could add another command, like
> say -mexec or something, that had this behavior to avoid compatibility
> problems.
What would you do in cases that are difficult to parse unambiguously,
where all four of "-exec", "{}", "+", and ";", appear in some order?
The POSIX behaviour (which we try to follow, but fail due to a bug)
is that you work out whether or not a "+" terminates the command by
checking whether or not it is immediately preceded by "{}". One possible
new behaviour would be to work out whether or not a "+" terminates the
command by checking whether or not it is immediately followed by "-foo",
where foo is a known primary (or where foo matches a pattern that also
recognises primaries that might be added in future, such as all lowercase
alphabetic).
A new "-mexec" primary would not have such a problem; it could just use
";" as the terminator, allow "{}" anywhere, and treat "+" as not being
special.
--apb (Alan Barrett)
Home |
Main Index |
Thread Index |
Old Index