Skip to content

fix: use portable grep -oE for Java version detection on macOS - #28

Open
WeToolX wants to merge 1 commit into
SimoneAvogadro:masterfrom
WeToolX:fix/macos-grep-oP
Open

fix: use portable grep -oE for Java version detection on macOS#28
WeToolX wants to merge 1 commit into
SimoneAvogadro:masterfrom
WeToolX:fix/macos-grep-oP

Conversation

@WeToolX

@WeToolX WeToolX commented Aug 26, 2026

Copy link
Copy Markdown

Fixes #27.

Problem

check-deps.sh fails on macOS because it uses the GNU-only grep -oP flag, which is not supported by BSD grep:

grep: invalid option -- P

This fallback runs when the primary sed extraction returns empty, which happens for OpenJDK versions that report a plain major version such as openjdk version "25".

Change

Replace the GNU-only regex with a portable one:

-    java_version=$(echo "$java_version_output" | grep -oP '\d+' | head -1)
+    java_version=$(echo "$java_version_output" | grep -oE '[0-9]+' | head -1)

Verification

On macOS (Darwin), after the change:

[OK] Java 25 detected
[OK] jadx 1.5.5 detected
[OK] vineflower CLI detected
[OK] dex2jar detected
[OK] apktool detected (optional)
[OK] adb detected (optional)

All dependencies are installed. Ready to decompile.

One-line change, no behavioral impact on Linux/GNU grep.

BSD grep on macOS does not support the GNU-only -P flag, causing check-deps.sh to fail with 'invalid option -- P' for OpenJDK versions that report a plain major version such as 25. Use grep -oE '[0-9]+' instead.
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.

check-deps.sh fails on macOS: GNU-only grep -oP unsupported by BSD grep

1 participant