Skip to content

Make HAS_ALLOW_UNSAFE case insensitive (closes #35) - #99

Merged
kdabir merged 1 commit into
kdabir:masterfrom
chiliec:fix-unsafe-case-insensitive
Sep 5, 2026
Merged

kdabir merged 1 commit into
kdabir:masterfrom
chiliec:fix-unsafe-case-insensitive

Conversation

@chiliec

@chiliec chiliec commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What

Closes #35.

HAS_ALLOW_UNSAFE was only honored when set to the exact lowercase y, so common truthy spellings (Y, yes, YES) were silently ignored and the dynamic/unsafe check never ran. This matches the maintainer's +1 for case-insensitivity in the issue thread.

Fix

The guard now accepts y/Y and yes (any case) via glob patterns in [[ ]]:

if [[ "${HAS_ALLOW_UNSAFE}" == [Yy] || "${HAS_ALLOW_UNSAFE}" == [Yy][Ee][Ss] ]]; then

Glob patterns keep this bash 3.2-safe (macOS) — no ${var,,}. No breaking change: HAS_ALLOW_UNSAFE=N/empty/anything else still disables the unsafe path exactly as before.

Tests

Added a unit test asserting Y, yes, Yes, YES all enable the unsafe path (output no longer contains foobar not understood).

Validation

$ bats tests/unit/unit-tests.bats
ok 5 env var 'HAS_ALLOW_UNSAFE' is case insensitive
...
$ shellcheck has   # clean, exit 0

Verified genuine RED→GREEN: reverting only the source guard back to == "y" turns the new test red (foobar not understood reappears for Y/yes/…); restoring the fix makes it green.

Note: two tests (testing coreutils commands, status code in quiet mode still equal to number of failed commands) fail on a clean master checkout on my machine too — they are pre-existing and outside this diff (which touches only the HAS_ALLOW_UNSAFE guard + one new test).

Happy to adjust (e.g. narrow to just [Yy] if you'd rather not accept yes).

Accept Y/yes/Yes/YES in addition to y so the toggle is not silently
ignored for common truthy spellings.

Closes kdabir#35
@kdabir
kdabir merged commit 7c419ee into kdabir:master Sep 5, 2026
@kdabir

kdabir commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution

social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
has 1.6.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* update link by @oooooooo in kdabir/has#90
* docs(README): add mise alternate installation documentation by @jylenhof in kdabir/has#92
* feat: added "just" as supported program by @goto-dev-null in kdabir/has#96
* fix: failing unit test assumes dev has `bc` installed by @goto-dev-null in kdabir/has#98
* feat: add shell completions for bash and zsh by @njg7194 in kdabir/has#93
* fix: color flags not working by @goto-dev-null in kdabir/has#97
* Make HAS_ALLOW_UNSAFE case insensitive (closes #35) by @chiliec in kdabir/has#99
* fix: stopped bzip2 from hanging by @goto-dev-null in kdabir/has#94

## New Contributors
* @oooooooo made their first contribution in kdabir/has#90
* @jylenhof made their first contribution in kdabir/has#92
* @goto-dev-null made their first contribution in kdabir/has#96
* @njg7194 made their first contribution in kdabir/has#93
* @chiliec made their first contribution in kdabir/has#99

**Full Changelog**: https://github.com/kdabir/has/compare/v1.5.2...v1.6.0</pre>
  <p>View the full release notes at <a href="https://github.com/kdabir/has/releases/tag/v1.6.0">https://github.com/kdabir/has/releases/tag/v1.6.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!19964
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.

HAS_ALLOW_UNSAFE only checks lowercase

2 participants