Skip to content

show-utils.sh: stop probing realpath with GNU-only options - #14906

Merged
sylvestre merged 7 commits into
uutils:mainfrom
Smicry:fix/show-utils-bsd-realpath
Sep 29, 2026
Merged

sylvestre merged 7 commits into
uutils:mainfrom
Smicry:fix/show-utils-bsd-realpath

Conversation

@Smicry

@Smicry Smicry commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

util/show-utils.sh resolved the repository root with realpath -mP and
recovered with a plain realpath on failure. On macOS realpath is the BSD
one, which takes no options, so the probe printed "realpath: illegal option
-- m" on every run before the fallback quietly did the right thing. That is
what the macOS Code Coverage job logs, and what a macOS contributor sees when
running ./util/show-utils.sh or cargo run --bin uudoc.

The root always exists, so cd and pwd -P give the same physical path with
no dependency on GNU coreutils. The test stubs a BSD-like realpath on PATH,
so the failure is caught on every platform, not only on macOS runners.

Closes #6607

@Smicry
Smicry force-pushed the fix/show-utils-bsd-realpath branch from 1b428ad to 1e40d76 Compare September 28, 2026 13:10
Comment thread util/test_show_utils.py Outdated
The Code Coverage job on macOS logged "realpath: illegal option -- m" on every
run: the script probed with GNU-only flags, then recovered via `||`. The repo
root always exists, so `cd` and `pwd -P` give the same physical path with no
dependency on GNU coreutils.
@Smicry
Smicry force-pushed the fix/show-utils-bsd-realpath branch from 1e40d76 to cc7ccd1 Compare September 28, 2026 15:00
Comment thread util/show-utils.sh
Comment thread util/show-utils.sh Outdated
The utility names are all in `.vscode/cspell.dictionaries/workspace.wordlist.txt`,
so the per-file list is redundant. The `OSTYPE` line has been dead since the
`$OSTYPE` check was replaced with a `command -v grealpath` lookup.
`set -e` alone is a no-op here: the two commands that can fail both sit in
pipelines whose rightmost stage succeeds, so the pipeline status is 0 even
when `sed` or `cargo` failed. `set -eo pipefail` propagates that.

Computing `default_utils` moves into the branch that uses it. It read
`Cargo.toml` relative to the caller's directory and ran before the `cd`, so
from outside the repository it produced an empty list, and under `pipefail`
it would abort a run that otherwise succeeds.
Comment thread util/show-utils.sh Outdated
Comment thread util/show-utils.sh Outdated
Comment thread util/show-utils.sh Outdated
ME_parent_dir_abs and project_main_dir existed only to be passed to cd, so
five steps computed a directory the script immediately changed into.
The regex selecting the coreutils package id matches the space, pipe, at and
hash separators that cargo has used across versions; without the comment the
pattern is not obvious.
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)

Comment thread util/show-utils.sh Outdated
Reading the feature list out of Cargo.toml needed tr, which Gentoo's portage
had to account for. cargo is already required to build the project, so this
drops an external tool without adding a dependency. Output is unchanged:
the same 78 utilities, verified against the previous implementation on cargo
1.88, 1.93 and 1.95.
show-utils.sh emits the fallback list one utility per line, which split(' ')
would leave as a single element. The tr-based pipeline it replaced left two
spaces between names, so the same call already produced 77 empty entries
whenever jq was missing.
@sylvestre
sylvestre merged commit 7e94315 into uutils:main Sep 29, 2026
93 of 94 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

@Smicry
Smicry deleted the fix/show-utils-bsd-realpath branch September 29, 2026 10:23
@oech3

oech3 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

#14947

@oech3

oech3 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Can we drop dirname too?

@Smicry

Smicry commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

Can we drop dirname too?

Agreed on dropping dirname, and I think sed should go too.

@oech3

oech3 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

We need to switch to Rust for Windows soon. But I drop it #14955 .

@oech3

oech3 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Where is the place *BSD.yml depend on GNU coreutils? Or did this PR remove such dep?

@Smicry

Smicry commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

Where is the place *BSD.yml depend on GNU coreutils? Or did this PR remove such dep?

coreutils in the BSD style job: openbsd.yml:50, freebsd.yml:44.

It was only there for show-utils.sh (openbsd.yml:83, freebsd.yml:73), which
used grealpath -mP. That -mP is the whole reason — GNU only, so on macOS
realpath just printed "illegal option -- m" every run. This PR uses cd + pwd -P
instead, so the dep is gone.

Didn't touch the workflows though, so the install line is still in place.

Also, the second half of that comment ("bash to use inline shell string
replacement") is about ${PWD//...} at openbsd.yml:106 — that's the bash
package, not coreutils.

@oech3

oech3 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

I tried to write in Rust. But it was too pain to maintain. But it seems uudoc use show-utils only for generating *.md. So is not it critical for Windows user?

It is needed for #8152 , but I'd like to keep bash and sed currently.

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.

ci: Code Coverage job on macOS shows realpath error

4 participants