bugfindutils - Bugs: bug #42501, Add -E option for FreeBSD/Mac OSX...


bug #42501: Add -E option for FreeBSD/Mac OSX compatibility

Submitted by:  None
Submitted on:  Tue Jun 3 18:32:14 2014  
Category: findSeverity: 1 - Wish
Item Group: NoneStatus: None
Privacy: PublicAssigned to: James Youngman <jay>
Originator Name: Chris BojarskiOriginator Email: -unavailable-
Open/Closed: OpenRelease: None
Fixed Release: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Wed Jun 4 20:27:55 2014, comment #2:

1. The FreeBSD man page for find points to re_format as its regex interpreter. On that page, it describes its modern regular expressions (REs) as being "as defined in IEEE Std 1003.2 (``POSIX.2'') ... roughly those of egrep(1); 1003.2 calls these ``extended'' REs." Now, I know GNU find has posix-egrep and posix-extended. I'm not sure which most closely matches the FreeBSD behavior, but it seems like it's definitely one of those two (assuming I understand those choices correctly).

2. The solution we came to on the script I was working on was to pipe the results through egrep. This ended up being sufficiently performant as we do not have a deep directory structure and we had -maxdepth set anyway. Between find and grep, though, were a call to basename and sort, which could become bottlenecks if they have to process a lot of paths that would later be filtered anyway. The current options are functional, but less elegant than using the tools already built into find (just not accessible cross-platform), and potentially affecting performance in long process chains. The idea would be that eventually, old versions would fall off, and we could update to using the new flag once we were confident that the new versions had enough adoption. This is, admittedly, a very long-term view.

I can't say I have had a lot of experience dealing with cross-platform compatibility with a utility like this (I am only contributing to the aforementioned script on the side), so I'm not sure what would be the best route to take dealing with the various versions. Beyond using egrep as a stopgap, I suppose one could do version checking on the installed find, but I have a feeling this is as inelegant as it sounds.

Chris Bojarski <cbojar>
Wed Jun 4 12:45:54 2014, comment #1:

This sounds useful. I have two questions. The first is about the intended behaviour of -E and the second is about the portability aspect.

1. The interpretation of posix-egrep is documented accurately in the Texinfo manual for find (accurate because the documentation is generated automatically from the controlling regex dialect bitmask value). Could you check in detail to make sure that FreeBSD's interpretation of -E really does yield the same regex dialect? I ask this because the only thing worse for portability than not offering the same option is to offer the same option with very subtle differences in behaviour...

2. If this flag is implemented you will have (at least) three versions of find to worry about: 1. FreeBSD grep, which supports -E. 2. New versions of NGU find, likewise. 3. Older versions of GNU find, which don't. What is your plan for cross-platform searching in this situation?

James Youngman <jay>
Project AdministratorIn charge of this item.
Tue Jun 3 18:32:14 2014, original submission:

I was working on a script recently that required cross-platform regular expression filtering. On Linux, the -regextype posix-egrep works like a charm, but this option is not cross-platform. On FreeBSD and Mac OSX, there is a -E option that looks equivalent to -regextype posix-egrep. I was hoping it might be possible to add a -E option that aliases to -regextype posix-egrep so that the same functionality can be used across different implementations.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by cbojar (Posted a comment)
  • -unavailable- added by jay (Posted a comment)
  • -unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Jun 4 12:45:54 2014jaySeverity3 - Normal=>1 - Wish
      Assigned toNone=>jay

    Back to the top

    Powered by Savane 3.1-cleanup