Re: find command regextype emacs does not support character classe
Bernhard Voelker <[email protected]> Thu, 19 Mar 2026 23:11:08 +0100
| Newsgroups | gmane.comp.gnu.findutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
On 3/19/26 18:06, Gasan wrote: > Hi all > > It seems that find command with regextype emacs or no regextype does not > support character classes in -regex option. > > For example: > > ``` > touch 123 > find . -regex './12[[:digit:]]' > ``` > > Findutils version 4.10.0 Indeed, while find-4.10.0 misses the file (because it does not understand character classes yet), the find program built from Git works: $ touch 123 $ ~/findutils-releases/fu-4.10.0/build/find/find . -regex './12[[:digit:]]' $ ~/findutils/find/find . -regex './12[[:digit:]]' ./123 This change comes from the recent change on the 'regex' gnulib module: efd5c380ff regex: match current Emacs behavior The new behavior is documented in the Texinfo manual since commit facc27e1804b, and also pushed to the web manual already: https://www.gnu.org/software/findutils/manual/html_node/find_html/emacs-regular-expression-syntax.html [...] Character classes are supported; for example ‘[[:digit:]]’ will match a single decimal digit. I've added a NEWS entry for this change - see attached patch and pushed at: https://cgit.git.savannah.gnu.org/cgit/findutils.git/commit/?id=34929da684212 Thanks for reporting this. Have a nice day, Berny
0001-NEWS-add-entry-for-recent-regex-alignment-with-Emacs.patch
(text/x-patch, 1.2 KB)
From 34929da684212a176e64be26eb764dc2fc35080a Mon Sep 17 00:00:00 2001 From: Bernhard Voelker <[email protected]> Date: Thu, 19 Mar 2026 22:59:09 +0100 Subject: [PATCH] NEWS: add entry for recent -regex alignment with Emacs * NEWS (Changes in find): Document that 'find -regex' now supports character classes (since gnulib commit efd5c380ff). --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index aa99ccf3..5c87f00c 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,11 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout) argument of the command to be run. While POSIX allows this for -exec, this is deemed insecure as an attacker could influence which files could be found. + 'find -regex' with the default or the 'emacs' regextype now aligns better with + Emacs behaviour, and therefore e.g. supports character classes: + $ touch 123 && find -regex './12[[:digit:]]' + ./123 + find now issues a warning when the punctuation operators '(', ')', '!' and ',' are passed with a leading dash, e.g. '-!'. Future releases will not accept that any more. Accepting that was rather a bug "since the beginning". -- 2.53.0