On Tue, Nov 17, 2020 at 01:06:05AM +0100, Alexander Hall wrote:
| On Mon, Nov 16, 2020 at 09:04:53AM +0100, Paul de Weerd wrote:
| > Hi Alexander,
| > 
| > On Sun, Nov 15, 2020 at 10:22:32PM +0100, Alexander Hall wrote:
| > | I googled for "POSIX find", and hit this:
| > | 
| > | https://pubs.opengroup.org/onlinepubs/009695399/utilities/find.html
| > | 
| > | => "Only a plus sign that follows an argument containing the two
| > |     characters "{}" shall punctuate the end of the primary expression.
| > |     Other uses of the plus sign shall not be treated as special."
| > 
| > Yep, I also found that when looking into this.  It's unforunate, as it
| > implies you can't use `-exec {} ... +` with e.g. ln, mv or cp, but oh
| > well.
| > 
| > (also, nitpicking, 'an argument containing the two characters "{}"'
| > includes an argument like "hh}hh{hh", which I'm pretty sure is not
| > what they mean)
| > 
| > | What you do in your diff is exactly that, treating it special.
| > 
| > I'm not sure I agree.  I make sure I do not treat it special unless
|                                                                ^^^^^^
| > it's at the end of the argument to 'exec'.  Can you elaborate on what
|   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| > you mean here?
| 
| If it is not following {}, then it should not be treated as such. You
| are assuming (or guessing) it was meant to be that special '+'.
| 
| Carefully crafted example of failing quoting of ';':
| 
| $ obj/find . -exec echo + ;    # Just print a '+' for every entry
| find: -exec: "+" should follow {}

In this case, I would say the error is correct: the + *is* at the end
of the argument to exec, and for -exec to work with +, it should
follow {}.

Since you failed to escape the semi-colon, the shell (not find)
discards it (uses it to separate find from the next command), so find
never sees the ';', you're actually doing `find . -exec echo +`; the
plus doesn't follow the requisite {}.

I could change the diff to see if there is no {} at all (as in your
carefully crafted example), and change the output based on that again.
However, using the diff that you proposed earlier in this thread (that
results in 'no terminating ";" or "{} +"') is probably the best way
forward (less code, still clear what the issue is).

| The more I read and think about it, I feel the original error message is
| actually correct in that there is no terminating ";" or "+", since the
| required condition for it is not fullfilled...

I still think the error is confusing for the user who, familiar with
'find -exec command {} arg \;', might assume the same would work for +.
Now, your diff seems like a better approach, given your argument.

Paul

-- 
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
                 http://www.weirdnet.nl/                 

Reply via email to