Skip to content

introduce IS_POSIXLY_CORRECT static#11934

Open
xtqqczze wants to merge 10 commits intouutils:mainfrom
xtqqczze:static-posixly-correct2
Open

introduce IS_POSIXLY_CORRECT static#11934
xtqqczze wants to merge 10 commits intouutils:mainfrom
xtqqczze:static-posixly-correct2

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

Follow-up #11853

@xtqqczze
Copy link
Copy Markdown
Contributor Author

Since we control the entrypoint, we could use unsafe mutable static instead:

static mut IS_POSIXLY_CORRECT: bool = false;

pub fn uu_main() {
    unsafe {
        IS_POSIXLY_CORRECT = env::var_os("POSIXLY_CORRECT").is_some();
    }
}

fn is_posixly_correct() -> bool {
    unsafe { IS_POSIXLY_CORRECT }
}

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/printf/printf-surprise is now passing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!

@xtqqczze xtqqczze force-pushed the static-posixly-correct2 branch 2 times, most recently from 8809cd0 to d38af2c Compare April 21, 2026 21:47
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 21, 2026

Merging this PR will not alter performance

✅ 309 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing xtqqczze:static-posixly-correct2 (5652044) with main (8cc048b)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@xtqqczze xtqqczze force-pushed the static-posixly-correct2 branch from d38af2c to 5652044 Compare April 21, 2026 22:41
@cakebaker
Copy link
Copy Markdown
Contributor

cakebaker commented Apr 22, 2026

Hm, what's the benefit of these changes? For example, in mktemp.rs there is a single check for the POSIXLY_CORRECT env variable in uumain, and using a global LazyLock seems overkill. But maybe I'm missing something...

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