Windows PowerShell scripts: parity polish after #8

Open
#14 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
powershell, shell
Domain
tooling

Research direction

Start by comparing decompile.ps1 with decompile.sh, especially Invoke-Jadx, Invoke-Fernflower, the both-engine summary, and Show-Structure; then review install-dep.ps1's Add-ToUserPath. The issue lists eight parity changes, but says substantial changes to the .sh scripts are underway and recommends waiting for them to merge. Done means the selected PowerShell behavior matches its bash counterpart and is tested on Windows.

Written by the indexing model from the issue text.

Description

Windows PowerShell scripts: parity polish after #8

Following the merge of #8 (huge thanks to @philjn for adding native Windows support — much appreciated, the structure is solid and the security review came back clean), I did a deeper side-by-side comparison of the four new PowerShell scripts against their bash counterparts on master.

That comparison surfaced a handful of items where the *.ps1 scripts could use a small follow-up to bring them to full feature parity — mostly behaviors that landed in *.sh via #10 (partial-success handling, fernflower timeout) and a couple of small refinements specific to the PowerShell implementation.

These are not blockers — the PS1 scripts work end-to-end on Windows — but bringing them to full parity will make the Windows experience match the Linux/macOS one.

Status

  • ✅ 3 items already addressed in commit f3fb1e9 on master: aligned install-dep.ps1 to the ThexXTURBOXx/dex2jar fork (mirroring #12).
  • ⏳ 8 items remaining below, grouped by area.

Remaining items

decompile.ps1 — feature parity with decompile.sh post-#10

1. Surface jadx exit code in Invoke-Jadx (~line 178)

The function currently returns $true regardless of jadx's exit code. The bash equivalent returns 0 (success), 2 (partial success — exit non-zero but Java files produced), or 1 (hard failure). Aligning the PS1 to the same trichotomy would let Invoke-DecompileSingle route the "both" engine flow correctly when jadx warnings occur.

2. Surface fernflower exit code in Invoke-Fernflower (~line 241)

Same pattern as #1 — capture $LASTEXITCODE and return 0/1/2 so the caller knows whether to continue or to fall back to the other engine.

3. Warning grep in the both engine summary (~line 302)

Select-String -Pattern '...|...' -SimpleMatch treats the | characters literally, so the "files with warnings/errors" count currently always reports 0. Removing -SimpleMatch (the pattern is already a valid regex) restores the intended behavior.

4. Show-Structure ordering (~lines 250-253)

The pipeline currently does Select-Object -First 20 | Sort-Object, which sorts only whichever 20 results came first from the filesystem enumeration. Swapping the order to Sort-Object | Select-Object -First 20 makes the top-level package list deterministic and aligned with the bash version. Also -Depth 2 could become -Depth 3 to match the bash -maxdepth 3.

5. Optional fernflower timeout (FERNFLOWER_TIMEOUT_SECONDS)

The bash version added a default 900s timeout in #10 to prevent indefinite hangs on Compose-heavy APKs. PowerShell doesn't have a native timeout(1); one option is Start-Job + Wait-Job -Timeout, another is System.Diagnostics.Process + WaitForExit($ms). Either approach would be welcome.

6. Intermediate dex2jar artifact directory

The bash version writes the converted jar into an intermediate/ subdirectory and only cleans it up on success (preserved on failure for debugging). Currently the PS1 writes it directly into the output dir alongside the sources.

7. Fallback for "Vineflower writes sources directly"

When Vineflower (rather than classic Fernflower) is the engine, output may land directly in the destination folder rather than as a result jar. The bash version handles both cases at lines ~296-312; the PS1 only handles the result-jar case.

install-dep.ps1 — minor refinement

8. Add-ToUserPath substring match is too permissive (line 76)

$currentPath -notlike "*$Dir*" returns false if PATH already contains a directory whose name is a superstring of $Dir (e.g. asking to add C:\foo when PATH already contains C:\foo\bar). Splitting on ; and doing an exact -notcontains check would be more correct.

How to take this forward

No pressure either way, @philjn — if any of these look interesting and you'd like to take a stab at one or more, you'd be very welcome. Otherwise I'm happy to get to them whenever I have a Windows VM available for proper testing, no rush at all.

Items 1-4 are the most user-visible (warning detection, exit code propagation, deterministic listing); 5-7 are nice-to-have parity with the recent bash improvements; 8 is a tiny edge case.

Feel free to drop a comment here, open a PR, or just leave it for me — whatever fits your schedule.

IMPORTANT

Since there is a large change I've been working on then the original .sh scripts will see some substantial changes. Before working on this issue it makes sense to wait after I merge the big changes.

Dominant language
Shell
Stars
8k
Forks
902
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SimoneAvogadro/android-reverse-engineering-skill

All issues in SimoneAvogadro/android-reverse-engineering-skill

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.