./sysutils/bfs, Breadth-first version of the UNIX find command

[ Image CVSweb ] [ Image Homepage ] [ Image RSS ] [ Image Required by ]


Branch: CURRENT, Version: 4.1.3, Package name: bfs-4.1.3, Maintainer: pkgsrc-users

bfs is a variant of the UNIX find command that operates breadth-first
rather than depth-first.


Required to build:
[pkgtools/cwrappers]

Master sites:

Filesize: 293.63 KB

Version history: (Expand)


CVS history: (Expand)


   2026-06-24 16:54:24 by Amitai Schleier | Files touched by this commit (4) | Package updated
Log message:
bfs: update to 4.1.3. Changes:

## Bug fixes

- Fixed a segfault when binaries built on macOS 26.4+ were run on older macOS
  versions (#229)
- Fixed a potential hang in the test suite
- Fixed `./configure`-time detection of `sysctlbyname()` on FreeBSD (#219)
- Bumped the default version number, which was missed in 4.1.1
- Fixed `./configure CFLAGS=...` being overridden by auto-detected flags
- Fixed the build for WASIX
- Fixed the build on Android < 11 (#215)
- `bfs` now takes system-wide open file limits into account.
  Previously, a handful of concurrent `bfs` instances could overwhelm a system
  with a low global limit, particularly macOS.
- Fixed an invalid optimization that transformed

      $ bfs -user you -or -user me

  into just

      $ bfs -user you

  The bug was originally introduced in bfs 2.0 (October 14, 2020). (#155)
- Only the last `-files0-from` argument now has any effect, to match GNU find
- Fixed `-execdir {}`, which was inadvertently broken in bfs 4.0
- Fixed `-fstype` with btrfs subvolumes (requires Linux 5.8+)
- Fixed `-ls` with timestamps very far in the future
- Fixed the `posix/exec_sigmask` test on mips64el Linux
- Fixed time-related tests with `mawk 1.3.4 20250131` (#152)
- Fixed a bug that could cause child processes (e.g. from `-exec`) to run with
  all signals blocked.
  The bug was introduced in version 3.3.
- Fixed a man page typo (#144)
- Fixed the build on PowerPC macOS (#145)
- Fixed a bug introduced in bfs 4.0.3 that colorized every file as if it had
  capabilities on non-Linux systems (#146)
- Fixed an assertion failure when `$LS_COLORS` contained escaped NUL bytes like
  `*\0.gz=`
- Fixed a use-after-free bug introduced in bfs 4.0 when unregistering and
  re-registering signal hooks.
  This could be reproduced with `bfs -nocolor` by repeatedly sending
  `SIGINFO`/`SIGUSR1` to toggle the status bar.
- Fixed a hang present since bfs 3.0 colorizing paths like `notdir/file`, where
  `notdir` is a symlink pointing to a non-directory file.
- Fixed `./configure --help`, which was broken since `bfs` 4.0
- Fixed compiler flag auto-detection on systems with non-GNU `sed`.
  This fixes a potential race condition on FreeBSD since `bfs` 4.0 due to the
  switch to `_Fork()` without passing `-z now` to the linker.
- Fixed `$MAKE distcheck` when `$MAKE` is not `make`, e.g. `gmake distcheck` on
  BSD
- Fixed some roff syntax issues in the `bfs` manpage
- Fixed an assertion failure optimizing expressions like `bfs -not \( -prune ,
  -type f \)` since `bfs` 3.1.
  Release builds were not affected, since their assertions are disabled and the
  behaviour was otherwise correct.
- `bfs` no longer prints a "suppressed errors" warning unless `-noerror` is
  actually suppressing errors
- Fixed commands like `./configure CC=clang --enable-release` that set variables
  before other options
- Fixed the build on RISC-V with GCC versions older than 14
- Fixed running `bfs` under Valgrind
- Fixed the exit code when failing to execute a non-existent command with
  `-exec`/`-ok` on some platforms including OpenBSD and HPPA
- Fixed `$LS_COLORS` case-sensitivity to match GNU ls more closely when the same
  extension is specified multiple times
- Fixed the `-status` bar on Solaris/Illumos
- Reduced the scope of the symbolic link loop change in version 3.3.
  `-xtype l` remains true for symbolic link loops, matching a change in GNU
  findutils 4.10.0.
  However, `-L` will report an error, just like `bfs` prior to 3.3 and other
  `find` implementations, as required by POSIX.
- `-regextype emacs` now supports shy (non-capturing) groups
- Fixed `-status` bar visual corruption when the terminal is resized
- `bfs` now prints a reset escape sequence when terminated by a signal in the
  middle of colored output (#138)
- `./configure CFLAGS=...` no longer overrides flags from `pkg-config` during
  configuration
- Fixed some rarely-used code paths that clean up after allocation failures
- On Linux, the `io_uring` feature probing introduced in `bfs` 3.1.2 only
  applied to one thread, causing all other threads to avoid using io_uring
  entirely.
  The probe results are now copied to all threads correctly.
- On Linux, we now check for supported `io_uring` operations before using them,
  which should fix `bfs` on 5.X series kernels that support `io_uring` but not
  all of `openat()`/`close()`/`statx()`
- Fixed a test failure triggered by certain filesystem types for `/tmp` (#131)
- Fixed parsing and interpretation of timezone offsets for explicit reference
  times used in `-*since` and `-newerXt`
- Fixed the build on m68k
- `-quit` and `-exit` could be ignored in the iterative deepening modes (`-S
  {ids,eds}`).
  This is now fixed.
  The bug was introduced in version 3.0.3.
- Fixed two possible errors in sort mode (`-s`):
  - Too many open files
  - Out of memory
- Fixed handling of FreeBSD union mounts
- Fixed `NO_COLOR` handling when it's set to the empty string
- Fixed some portability issues:
  - OpenBSD
  - NetBSD
  - DragonFly BSD
  - Illumos
- Fixed a segfault when reporting errors under musl
- Iterative deepening modes (`-S {ids,eds}`) were performing iterative
  *breadth*-first searches since `bfs` 3.0, negating any advantages they may
  have had over normal breadth-first search.
  They now do iterative *depth*-first searches as expected.
- Fixed a linked-list corruption that could lead to an infinite loop on macOS
  and other non-Linux, non-FreeBSD platforms
- Fixed an out-of-bounds memory read that could occur when escaping a string
  containing an incomplete multi-byte character
- Traversal fixes that mostly affect large directory trees (#107)
  - `bfs` could encounter `EMFILE`, close a file, and retry many times,
    particularly with `-j1`
  - Breadth-first search could become highly unbalanced, negating many of the
    benefits of `bfs`
  - On non-{Linux,FreeBSD} platforms, directories could stay open longer than
    necessary, consuming extra memory
- Fixed handling of the "normal text" color (`no` in `$LS_COLORS`) to \ 
match GNU
  ls

## New features

- Added support for the `$LSCOLORS` variable used by FreeBSD and macOS (#54,
  #157)
- Implemented `./configure --version=X.Y.Z`, mainly for packagers to override
  the version number
- To match BSD `find` (and the POSIX Utility Syntax Guidelines), multiple flags
  can now be given in a single argument like `-LEXO2`.
  Previously, you would have had to write `-L -E -X -O2`.
- Explicit timestamps can now be written as `@SECONDS_SINCE_EPOCH`.
  For example, `bfs -newermt @946684800` will print files modified since January
  1, 2000 (UTC).
- The new `-noerror` option suppresses all error messages during traversal.
  (#142)
- The `-status` bar can now be toggled by `SIGINFO`
  (<kbd>Ctrl</kbd>+<kbd>T</kbd>) on systems that support \ 
it, and `SIGUSR1` on
  other systems
- `-regextype` now supports all regex types from GNU find (#21)
- File birth times are now supported on OpenBSD
- New `-limit N` action that quits immediately after `N` results
- Implemented `-context` (from GNU find) for matching SELinux contexts (#27)
- Implemented `-printf %Z` for printing SELinux contexts
- On Linux, `bfs` now uses io_uring for async I/O
- On all platforms, `bfs` can now perform `stat()` calls in parallel,
  accelerating queries like `-links`, `-newer`, and `-size`, as well as
  colorized output
- On FreeBSD, `-type w` now works to find whiteouts like the system `find`
- `bfs` now reads directories asynchronously and in parallel (#101).
  Performance is significantly improved as a result.
  Parallelism is controlled by the new `-j` flag, e.g. `-j1`, `-j2`, etc.

## Changes

- Switched from C17 to C23 by default.
  C17 is still supported as a fallback as long as your compiler supports some
  common extensions.
- `bfs` now takes CPU affinity into account when picking how many threads to use
- `-execdir /bin/...` is now allowed even with a relative path in `$PATH`
- *Expect* is no longer a test suite dependency
- Fixed the build against old liburing versions (#147)
- Async I/O performance optimizations
- Minor refactoring of the build system
- `-mount` now excludes mount points entirely, to comply with the recently
  published POSIX 2024 standard.
  Use `-xdev` to include the mount point itself, but not its contents.
  `bfs` has been warning about this change since version 1.5.1 (September 2019).
- `-perm` now takes the current file creation mask into account when parsing a
  symbolic mode like `+rw`, as clarified by POSIX defect 1392.
    This matches the behaviour of BSD `find`, contrary to the behaviour of GNU
    `find`.
- Symbolic link loops are now treated like other broken links, rather than an
  error
- `./configure` now expects `--with-libacl`, `--without-libcap`, etc. rather
  than `--enable-`/`--disable-`
- The ` ` (space) flag is now restricted to numeric `-printf` specifiers
- The build system has been rewritten, and there is now a configure step:

      $ ./configure
      $ make

  See `./configure --help` or docs/BUILDING.md for more details.
- Improved platform support
  - Implemented `-acl` on Solaris/Illumos
  - Implemented `-xattr` on DragonFly BSD
- Performance and scalability improvements
- The file count in `bfs -status` now has a thousands separator
- Improved `bfs -j2` performance
- Optimized `-exec` by using `posix_spawn()` when possible, which can avoid the
  overhead of `fork()`
- `-execdir` and `-okdir` are now rejected if `$PATH` contains a relative path,
  matching the behaviour of GNU find
- Leading whitespace is no longer accepted in integer command line arguments
  like `-links ' 1'`
- Iterative deepening modes (`-S {ids,eds}`) were optimized by delaying teardown
  until the very end
- Parallel depth-first search (`-S dfs`) was optimized to avoid enqueueing every
  file separately
- `-files0-from` now allows an empty set of paths to be given, matching GNU
  findutils 4.9.0
- Reduced memory consumption in multi-threaded searches
- Many man page updates
- `bfs` now uses the C17 standard version, up from C11
- Due to #101, `bfs` now requires some additional C and POSIX features:
  - Standard C atomics (`<stdatomic.h>`)
  - POSIX threads (`<pthread.h>`)
- `$LS_COLORS` extensions written in different cases (e.g.
  `*.jpg=35:*.JPG=01;35`) are now matched case-sensitively, to match the new
  behaviour of GNU ls since coreutils version 9.2
- Added a warning/error if `$LS_COLORS` can't be parsed, depending on whether
  `-color` is requested explicitly
- Filenames with control characters are now escaped when printing with `-color`
- Build flags like `WITH_ONIGURUMA` have been renamed to `USE_ONIGURUMA`

## Other changes

- Fixed running the tests as root on Linux `8b24de3`
- Fixed some tests on Android `2724dfb` `0a5a80c`
- Stopped relying on non-POSIX touch(1) features in the tests.
  This should fix the tests on at least OpenBSD.
  `2d5edb3`
- User/group caches are now filled lazily instead of eagerly `b41dca5`
- More caches and I/O streams are flushed before -exec/-ok `f98a1c4`
- Fixed various memory safety issues found by fuzzing
  `712b137` `5ce883d` `da02def` `c55e855`
- Fixed a test failure on certain macOS versions `8b24de3`
- Mitigated a race condition when determining filesystem types (#97)
- Lots of refactoring and optimization
- Fixed use of uninitialized memory on parsing errors involving `-fprintf`
- Fixed Android build issues (#96)
- Refactored the test suite
- Fix `stat()` errors on GNU Hurd systems with glibc older than 2.35
- Added fish shell tab completion (#94).
  Thanks @xfgusta!
- Fixed deleting large NFS directories on FreeBSD (#67).
- Added support for a `bfs`-specific `BFS_COLORS` environment variable.
- Refactored the build system, directory structure, and documentation (#88, #89,
  #91).
  Thanks @ElectronicsArchiver!
- Added `zsh` completion (#86).
  Thanks @VorpalBlade!
- Updated the default color scheme to match GNU coreutils 9.1.
  Files with capabilities set are no longer colored differently by default,
  resulting in a significant performance improvement.
- Became less aggressive at triggering automounts
- Added support for out-of-tree builds with `BUILDDIR`
- Added compiler-style context for errors and warnings.
  Errors look like this:

      $ bfs -nam needle
      bfs: error: bfs -nam needle
      bfs: error:     ~~~~
      bfs: error: Unknown argument; did you mean -name?

  and warnings look like this:

      $ bfs -print -name 'needle'
      bfs: warning: bfs -print -name needle
      bfs: warning:            ~~~~~~~~~~~~
      bfs: warning: The result of this expression is ignored.
- Updated from C99 to C11
- Fixed the tests when built against musl
- Fixed a build error reported on Manjaro
- Fixed the build when Oniguruma is not installed in the default search paths
  (#82)
- Fixed string encoding bugs with Oniguruma enabled
- Fixed regex error reporting bugs
- Added the Oniguruma regular expression library as an (optional, but enabled by
  default) dependency (#81).
  Oniguruma supports more regular expression syntax types than the POSIX regex
  API, and often performs better.
  To build `bfs` without this new dependency, do `make WITH_ONIGURUMA=` to
  disable it.
  Thanks @data-man!
- Added support for the `ed`, `emacs`, `grep`, and `sed` regular expression
  types (#21)
- Before executing a process with `-execdir`/`-okdir`, `bfs` now ensures all
  output streams are flushed.
  Previously, I/O from subprocesses could be interleaved unpredictably with
  buffered I/O from `bfs` itself.
- Fixed the build on Debian kFreeBSD
- Fixed a crash on GNU Hurd when piping bfs's output
- Fixed a double-`close()` on non-Linux platforms if `fdopendir()` fails
- Reduced memory allocations on startup
- More tweaks to `PAGER` and `LESS` handling for `bfs -help` (#76)
- Use 512-byte blocks for `-ls` when `POSIXLY_CORRECT` is set (#77)
- Implemented `-files0-from FILE` to take a list of `'\0'`-separated starting
  paths.
  GNU find will implement the same feature in an upcoming release.
- Added colors to `-printf` output (#62)
- Faster recovery from `E2BIG` during `-exec`
- Fixed some incorrect coloring of broken links when links are being followed
  (`-L`)
- Made the tests work when run as root by dropping privileges.
  This may be helpful for certain packaging or CI environments, but is not
  recommended.
- Treat empty `PAGER` and `LESS` environment variables like they're unset, for
  `bfs -help` (#71).
  Thanks @markus-oberhumer!
- The soft `RLIMIT_NOFILE` is now raised automatically to a fairly large value
  when possible.
  This provides a minor performance benefit for large directory trees.
- Implemented time units for `-mtime` as found in FreeBSD find (#75)
- Fixed `-hidden` on hidden start paths
- Added a Bash completion script.
  Thanks @bmundt6!
- Fixed rounding in `-used`.
  Corresponding fixes were made to GNU find in version 4.8.0.
- Optimized the open directory representation.
  On Linux, much libc overhead is bypassed by issuing syscalls directly.
  On all platforms, a few fewer syscalls and open file descriptors will be used.
- Implemented `-flags` from BSD find
- Added a new `-status` option that displays the search progress in a bar at the
  bottom of the terminal
- Fixed an optimizer bug introduced in version 2.0 that affected some
  combinations of `-user`/`-group` and `-nouser`/`-nogroup`
- #8: New `-exclude <expression>` syntax to more easily and reliably filter out
  paths.
  For example:

      bfs -name config -exclude -name .git

  will find all files named `config`, without searching any directories (or
  files) named `.git`.
  In this case, the same effect could have been achieved (more awkwardly) with
  `-prune`:

      bfs ! \( -name .git -prune \) -name config

  But `-exclude` will work in more cases:

      # -exclude works with -depth, while -prune doesn't:
      bfs -depth -name config -exclude -name .git

      # -exclude applies even to paths below the minimum depth:
      bfs -mindepth 3 -name config -exclude -name .git
- #30: `-nohidden` is now equivalent to `-exclude -hidden`.
  This changes the behavior of command lines like

      bfs -type f -nohidden

  to do what was intended.
- Optimized the iterative deepening (`-S ids`) implementation
- Added a new search strategy: exponential deepening search (`-S eds`).
  This strategy provides many of the benefits of iterative deepening, but much
  faster due to fewer re-traversals.
- Fixed an optimizer bug that could skip `-empty`/`-xtype` if they didn't always
  lead to an action
- Implemented `-xattrname` to find files with a particular extended attribute
  (from macOS find)
- Made `-printf %l` still respect the width specifier (e.g. `%10l`) for
  non-links, to match GNU find
- Made `bfs` fail if `-color` is given explicitly and `LS_COLORS` can't be
  parsed, rather than falling back to non-colored output
- Fixed `-ls` printing numeric IDs instead of user/group names in large
  directory trees
- Cached the user and group tables for a performance boost
- Fixed interpretation of "default" ACLs
- Implemented `-s` flag to sort results
- Implemented `-newerXt` (explicit reference times), `-since`, `-asince`, etc.
- Fixed `-empty` to skip special files (pipes, devices, sockets, etc.)
- Fixed the build on NetBSD
- Added support for NFSv4 ACLs on FreeBSD
- Added a `+` after the file mode for files with ACLs in `-ls`
- Supported more file types (whiteouts, doors) in symbolic modes for
  `-ls`/`-printf %M`
- Implemented `-xattr` on FreeBSD
   2021-10-26 13:20:30 by Nia Alarie | Files touched by this commit (630)
Log message:
sysutils: Replace RMD160 checksums with BLAKE2s checksums

All checksums have been double-checked against existing RMD160 and
SHA512 hashes
   2021-10-07 16:58:44 by Nia Alarie | Files touched by this commit (630)
Log message:
sysutils: Remove SHA1 hashes for distfiles
   2019-12-28 13:16:53 by Makoto Fujiwara | Files touched by this commit (1)
Log message:
(licenses/0-clause-bsd, sysutils/bfs) Rename license isc-AUTHOR to 0-clause-bsd

 sysutils/bfs/Makefile  .. convert to LICENSE=  0-clause-bsd
 licenses/0-clause-bsd  .. renamed from isc-AUTHOR (with minor edit on YEAR)
 licenses/isc-AUTHOR    .. remvoed
   See thread of starting at
   http://mail-index.netbsd.org/tech-pkg/2019/12/15/msg022307.html
   Thanks
   2019-12-15 13:29:02 by Makoto Fujiwara | Files touched by this commit (4)
Log message:
(sysutils/bfs) Updated from 1.1.3 to 1.5.1

1.5.1
-----
**September 14, 2019**

- Added a warning to `-mount`, since it will change behaviour in the next POSIX \ 
revision
- Added a workaround for environments that block `statx()` with `seccomp()`, \ 
like older Docker
- Fixed coloring of nonexistent leading directories
- Avoided calling `stat()` on all mount points at startup

1.5
---
**June 27, 2019**

- New `-xattr` predicate to find files with extended attributes
- Fixed the `-acl` implementation on macOS
- Implemented depth-first (`-S dfs`) and iterative deepening search (`-S ids`)
- Piped `-help` output into `$PAGER` by default
- Fixed crashes on some invalid `LS_COLORS` values

1.4.1
-----
**April 5, 2019**

- Added a nicer error message when the tests are run as root
- Fixed detection of comparison expressions with signs, to match GNU find for \ 
things like `-uid ++10`
- Added support for https://no-color.org/
- Decreased the number of `stat()` calls necessary in some cases

1.4
---
**April 15, 2019**

- New `-unique` option that filters out duplicate files \ 
(https://github.com/tavianator/bfs/issues/40)
- Optimized the file coloring implementation
- Fixed the coloring implementation to match GNU ls more closely in many corner cases
  - Implemented escape sequence parsing for `LS_COLORS`
  - Implemented `ln=target` for coloring links like their targets
  - Fixed the order of fallbacks used when some color keys are unset
- Add a workaround for incorrect file types for bind-mounted files on Linux \ 
(https://github.com/tavianator/bfs/issues/37)

1.3.3
-----
**February 10, 2019**

- Fixed unpredictable behaviour for empty responses to `-ok`/`-okdir` caused by \ 
an uninitialized string
- Writing to standard output now causes `bfs` to fail if the descriptor was closed
- Fixed incomplete file coloring in error messages
- Added some data flow optimizations
- Fixed `-nogroup`/`-nouser` in big directory trees
- Added `-type w` for whiteouts, as supported by FreeBSD `find`
- Re-wrote the `-help` message and manual page

1.3.2
-----
**January 11, 2019**

- Fixed an out-of-bounds read if LS_COLORS doesn't end with a `:`
- Allowed multiple debug flags to be specified like `-D opt,tree`

1.3.1
-----
**January 3, 2019**

- Fixed some portability problems affecting FreeBSD

1.3
---
**January 2, 2019**

New features:

- `-acl` finds files with non-trivial Access Control Lists (from FreeBSD)
- `-capable` finds files with capabilities set
- `-D all` turns on all debugging flags at once

Fixes:

- `LS_COLORS` handling has been improved:
  - Extension colors are now case-insensitive like GNU `ls`
  - `or` (orphan) and `mi` (missing) files are now treated differently
  - Default colors can be unset with `di=00` or similar
  - Specific colors fall back to more general colors when unspecified in more places
  - `LS_COLORS` no longer needs a trailing colon
- `-ls`/`-fls` now prints the major/minor numbers for device nodes
- `-exec ;` is rejected rather than segfaulting
- `bfs` now builds on old Linux versions that require `-lrt` for POSIX timers
- For files whose access/change/modification times can't be read, `bfs` no \ 
longer fails unless those times are needed for tests
- The testsuite is now more correct and portable

1.2.4
-----
**September 24, 2018**

- GNU find compatibility fixes for `-printf`:
  - `%Y` now prints `?` if an error occurs resolving the link
  - `%B` is now supported for birth/creation time (as well as `%W`/`%w`)
  - All standard `strftime()` formats are supported, not just the ones from the \ 
GNU find manual
- Optimizations are now re-run if any expressions are reordered
- `-exec` and friends no longer leave zombie processes around when `exec()` fails

1.2.3
-----
**July 15, 2018**

- Fixed `test_depth_error` on filesystems that don't fill in `d_type`
- Fixed the build on Linux architectures that don't have the `statx()` syscall \ 
(ia64, sh4)
- Fixed use of AT_EMPTY_PATH for fstatat on systems that don't support it (Hurd)
- Fixed `ARG_MAX` accounting on architectures with large pages (ppc64le)
- Fixed the build against the upcoming glibc 2.28 release that includes its own \ 
`statx()` wrapper

1.2.2
-----
**June 23, 2018**

- Minor bug fixes:
  - Fixed `-exec ... '{}' +` argument size tracking after recovering from `E2BIG`
  - Fixed `-fstype` if `/proc` is available but `/etc/mtab` is not
  - Fixed an uninitialized variable when given `-perm +rw...`
  - Fixed some potential "error: 'path': Success" messages
- Reduced reliance on GNU coreutils in the testsuite
- Refactored and simplified the internals of `bftw()`

1.2.1
-----
**February 8, 2018**

- Performance optimizations

1.2
---
**January 20, 2018**

- Added support for the `-perm +7777` syntax deprecated by GNU find (equivalent \ 
to `-perm /7777`), for compatibility with BSD finds
- Added support for file birth/creation times on platforms that report it
  - `-Bmin`/`-Btime`/`-Bnewer`
  - `B` flag for `-newerXY`
  - `%w` and `%Wk` directives for `-printf`
  - Uses the `statx(2)` system call on new enough Linux kernels
- More robustness to `E2BIG` added to the `-exec` implementation

1.1.4
-----
**October 27, 2017**

- Added a man page
- Fixed cases where multiple actions write to the same file
- Report errors that occur when closing files/flushing streams
- Fixed "argument list too long" errors with `-exec ... '{}' +`
   2019-09-09 11:32:37 by Nia Alarie | Files touched by this commit (2)
Log message:
bfs: Fix building on NetBSD
   2017-10-25 16:57:50 by Filip Hajny | Files touched by this commit (4)
Log message:
Import bfs-1.1.3 as sysutils/bfs.

bfs is a variant of the UNIX find command that operates breadth-first
rather than depth-first.