Skip to content

fix: local-wp --help silently exits 1 with zero output#125

Merged
noelsaw1 merged 2 commits intomainfrom
copilot/fix-local-wp-help-crash
Mar 24, 2026
Merged

fix: local-wp --help silently exits 1 with zero output#125
noelsaw1 merged 2 commits intomainfrom
copilot/fix-local-wp-help-crash

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

local-wp --help (and every invocation) silently crashed under set -e because detect_php_bin returned exit code 1 when no macOS Local by Flywheel PHP directories exist — killing the script before any output was produced.

Root cause

set -euo pipefail
# ...
PHP_BIN="${PHP_BIN:-$(detect_php_bin)}"  # detect_php_bin returns 1 → set -e kills script

Any invocation on a system without Local installed (Linux, CI, fresh macOS) hit this on the way to the argument parser — including --help.

Changes (dist/bin/local-wp)

  • --help/-h handled before PHP detection — early arg scan at the top exits cleanly before detect_php_bin is ever called
  • detect_php_bin always returns 0 — explicit return 0 on every path; empty stdout signals "not found"
  • || true guard on PHP_BIN assignment — belt-and-suspenders against any future regression:
    PHP_BIN="${PHP_BIN:-$(detect_php_bin || true)}"
  • Graceful fallback to system PHP — when Local PHP is absent, warns and continues rather than dying silently; errors with actionable message if no PHP at all

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Fix silent crash when running local-wp --help fix: local-wp --help silently exits 1 with zero output Mar 24, 2026
Copilot AI requested a review from noelsaw1 March 24, 2026 21:06
@noelsaw1 noelsaw1 marked this pull request as ready for review March 24, 2026 21:26
@noelsaw1 noelsaw1 merged commit 34e4ac1 into main Mar 24, 2026
1 check passed
noelsaw1 added a commit that referenced this pull request Mar 24, 2026
local-wp is a WP-CLI wrapper for Local by Flywheel and lives in
AI-DDTK (bin/local-wp). It was mistakenly added to WPCC's dist/bin/
by Copilot in PR #125. WPCC's dist/bin/ is for scanner-related scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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