Skip to content

Replace find -printf, which does not exist on macOS - #18

Open
bmesuere wants to merge 1 commit into
feature/frag-gene-scan-rsfrom
fix/portable-find
Open

Replace find -printf, which does not exist on macOS#18
bmesuere wants to merge 1 commit into
feature/frag-gene-scan-rsfrom
fix/portable-find

Conversation

@bmesuere

@bmesuere bmesuere commented Aug 18, 2026

Copy link
Copy Markdown
Member

Both scripts listed the configuration directory with:

find -H "$(getconfigdir)" -mindepth 1 -maxdepth 1 -printf '%P\n' | sort -n

-printf is a GNU extension. macOS ships BSD find, so this fails with find: -printf: unknown primary or operator. The effects:

  • umgap-visualize.sh -t broke outright — it could not build a frequency table at all.
  • umgap-analyse.sh silently found no data version, so it reported "No data version found valid for all samples. Please run umgap-setup." even with a perfectly good configuration.

Replaced with a small list_versions helper using a glob and basename.

Verification

GNU find is installed here as gfind, so this is a direct comparison rather than a reading of the man page. On a directory containing version directories and a symlink:

helper:  FragGeneScanRs 3 2020 2024
gfind:   FragGeneScanRs 3 2020 2024

Identical, including the numeric ordering. Also matched on a dangling symlink, which find -H lists and a naive [ -e ] test would have dropped — hence the || [ -L ].

Checked the empty-directory case under /bin/sh with set -e (which umgap-visualize.sh uses): the unmatched glob stays literal, the guard filters it, output is empty and the exit status is 0.

End to end on macOS, both now work:

$ umgap-visualize.sh -c <cfg> -t taxa.fa
taxon id,taxon name,_tmp_taxa.fa
562,Escherichia coli,2

$ umgap-analyse.sh -c <cfg> ...
debug: using version '2024'

Both scripts listed the configuration directory with

    find -H "$(getconfigdir)" -mindepth 1 -maxdepth 1 -printf '%P\n'

-printf is a GNU extension. On macOS, whose find is the BSD one, this fails
with "find: -printf: unknown primary or operator", which broke
umgap-visualize.sh -t outright and left umgap-analyse.sh unable to find any
data version.

Replaced with a small helper using a glob and basename. Its output is
byte-identical to the GNU find command on a directory holding version
directories and a symlink, in the same numeric order, and it lists dangling
symlinks just as find -H did.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 18, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants