On November 17, 2020 1:11:42 PM GMT+01:00, Paul de Weerd <we...@weirdnet.nl> 
wrote:
>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 {}.

1. The failed escaping of ";" was intentional, to hint that the intent really 
was not to use "+" as the delimiter.
2. A "+" not following a "{}" is by itself no indication that it was intended 
to end the -exec part. You are making assumptions, which in the case above 
would be wrong.

Thus, the only thing we can know for sure is that there just simply is no 
terminating ";" or "+".

I'd be fine with changing the "+" to "{} +" though. I did try separating them 
into "{}" "+" to not indicate they should be one single argument, but I still 
believe the former is easier on the eye and gives a good enough hint.

>
>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.

Not sure exactly what you mean, but I think you'd just be assuming 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).

Yeah. I strongly agree.

/Alexander


>
>| 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

Reply via email to