[bug #66365] find -exec treats + as special when it shouldn't

Geoff Clare <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
URL:
  <https://savannah.gnu.org/bugs/?66365>

                 Summary: find -exec treats + as special when it shouldn't
                   Group: findutils
               Submitter: geoffclare
               Submitted: Tue 22 Oct 2024 10:43:11 AM UTC
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: None
           Fixed Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Tue 22 Oct 2024 10:43:11 AM UTC By: Geoff Clare <geoffclare>
POSIX requires that a "+" supplied to "-exec" is only treated as special when
it follows an argument that is exactly "{}".

So in the command:

find . -prune -exec echo x{} + \;

the "+" is not special and the command should output "x. +", but GNU find
treats it as special:

$ find . -prune -exec echo x{} + \;         
find: In ‘-exec ... {} +’ the ‘{}’ must appear by itself, but you
specified ‘x{}’

Tested with findutils 4.9.0 as included in Debian bookworm.

Here's the relevant text from POSIX.1-2024 (it was the same in .1-2008):

"Only a <plus-sign> that immediately follows an argument containing only the
two characters "{}" shall punctuate the end of the primary expression. Other
uses of the <plus-sign> shall not be treated as special."








    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66365>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCZxeBwgAKCRCqLAuaBUf3
TheyAQClpUTZHTQY7PV3/7ipoAXJ8REfStYpBRW6tprcfPVdiwD8CltW4DRb/etO
+ZwDiZgUPzuCwtS9IrJnX/BkQrJUBQc=
=0Xea
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.