Skip to content

#4937: fix(wp-helper): replace bash -lc with bash -c to stop SSH stdout being swallowed#4938

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t4937-wp-helper-ssh-stdout
Mar 15, 2026
Merged

#4937: fix(wp-helper): replace bash -lc with bash -c to stop SSH stdout being swallowed#4938
marcusquinn merged 1 commit intomainfrom
bugfix/t4937-wp-helper-ssh-stdout

Conversation

@marcusquinn
Copy link
Owner

Summary

  • Replaces bash -lc with bash -c in both SSH execution paths (hostinger|closte and hetzner|cloudways|cloudron) so remote login shell startup files (~/.bash_profile, ~/.bashrc) are not sourced — these files on managed hosting servers commonly redirect or close stdout before wp runs, causing all WP-CLI output to be silently discarded.
  • Redirects the [INFO] Running on ... diagnostic line in run_wp_command to stderr, so callers can capture clean WP-CLI stdout without mixing it with log output.

Root cause

bash -lc invokes a login shell on the remote server. Cloudways (and other managed hosts) source startup files that include guards like mesg n or tty -s && mesg n, or other interactive-shell redirections that close/redirect fd1 before the wp command runs. The -n SSH flag (stdin from /dev/null) is unrelated — the issue is the login shell, not stdin.

Direct SSH without bash -lc (as in the reporter's working example) bypasses this entirely.

Changes

  • .agents/scripts/wp-helper.sh — two bash -lcbash -c substitutions (lines 340, 347 pre-patch); one print_info redirected to stderr (line 382 pre-patch)

Verification

ShellCheck: zero new violations (SC1091 info pre-existing, unrelated to this change).

Functional verification requires a live Cloudways/Hetzner/Cloudron site — the reporter can confirm with:

wp-helper.sh <any-cloudways-site> "option get siteurl"
# Expected: [INFO] line on stderr + site URL on stdout

Closes #4937

…g swallowed

Login shell startup files (~/.bash_profile, ~/.bashrc) on remote servers
(Cloudways, Hetzner, Cloudron, Hostinger, Closte) can redirect or close
stdout before wp runs. Dropping the -l flag avoids sourcing those files
while still executing the cd+wp command correctly.

Also redirect the [INFO] diagnostic line in run_wp_command to stderr so
callers can capture clean WP-CLI stdout without mixing it with log output.

Fixes #4937
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 45a120f5-a27a-4f1a-8876-dbb6f30a47b0

📥 Commits

Reviewing files that changed from the base of the PR and between 60aa4b1 and 7f837c3.

📒 Files selected for processing (1)
  • .agents/scripts/wp-helper.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t4937-wp-helper-ssh-stdout
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where WP-CLI output was being suppressed on certain managed hosting providers when commands were executed via SSH. The primary fix involves modifying the SSH command execution to bypass login shell startup files, which were inadvertently interfering with standard output. Additionally, informational messages have been rerouted to stderr to maintain the integrity of WP-CLI's standard output.

Highlights

  • SSH Command Execution: Replaced bash -lc with bash -c in SSH commands for both password-based and key-based authentication paths. This change prevents remote login shell startup files from being sourced, which often redirect or close stdout, leading to WP-CLI output being silently discarded on managed hosting environments.
  • Diagnostic Output: Redirected the [INFO] Running on ... diagnostic message in run_wp_command to stderr. This ensures that callers can capture clean WP-CLI stdout without it being mixed with informational log output.
Changelog
  • .agents/scripts/wp-helper.sh
    • Replaced bash -lc with bash -c in two SSH command invocations within the execute_wp_via_ssh function.
    • Modified the print_info call in run_wp_command to redirect its output to stderr.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 362 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Mar 15 17:35:09 UTC 2026: Code review monitoring started
Sun Mar 15 17:35:10 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 362

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 362
  • VULNERABILITIES: 0

Generated on: Sun Mar 15 17:35:12 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn merged commit 3ebddb3 into main Mar 15, 2026
17 of 18 checks passed
@marcusquinn marcusquinn deleted the bugfix/t4937-wp-helper-ssh-stdout branch March 15, 2026 17:36
@sonarqubecloud
Copy link

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly resolves an issue where command output was being suppressed by remote login shell startup files by switching from bash -lc to bash -c. The change to redirect diagnostic information to stderr is also a good improvement for separating log output from command results. I have added one suggestion to further improve the diagnostic logging by properly quoting command arguments, which will make debugging easier, especially for commands with arguments containing spaces.

site_type=$(echo "$site_config" | jq -r '.type')

print_info "Running on $site_name ($site_type): wp ${wp_args[*]}"
print_info "Running on $site_name ($site_type): wp ${wp_args[*]}" >&2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using ${wp_args[*]} can create ambiguous log output if any of the arguments contain spaces. For example, a command with an argument like 'John Doe' would be logged with the quotes removed, which is misleading.

To make the logged command accurate and easier to debug, I suggest quoting the arguments for display. You can use printf '%q ' to safely quote each argument.

Suggested change
print_info "Running on $site_name ($site_type): wp ${wp_args[*]}" >&2
print_info "Running on $site_name ($site_type): wp $(printf '%q ' "${wp_args[@]}")" >&2

@marcusquinn marcusquinn added the review-feedback-scanned Merged PR already scanned for quality feedback label Mar 15, 2026
marcusquinn added a commit that referenced this pull request Mar 15, 2026
…itter

Root cause: multiple pulse runners evaluating the same issue simultaneously
create duplicate PRs. Process-based dedup (has_worker_for_repo_issue,
is-duplicate) only sees local processes — invisible across machines.

Fix 1: Add is-assigned command to dispatch-dedup-helper.sh that queries
GitHub assignees before dispatch. If another runner already self-assigned,
skip the issue. This is the primary cross-machine dedup guard.

Fix 2: Add 0-30s random startup jitter to pulse-wrapper.sh so concurrent
launchd-triggered pulses don't evaluate issues at the same instant.
Configurable via PULSE_JITTER_MAX (set to 0 to disable).

Fix 3: Update pulse.md dispatch instructions to enforce the assignee
check as a mandatory step alongside existing local process dedup.

Observed: PR #4940 duplicated PR #4938 for issue #4937 because
alex-solovyev's pulse dispatched 2 min after marcusquinn self-assigned,
interpreting the in-progress worker as 'failed'.
marcusquinn added a commit that referenced this pull request Mar 15, 2026
…tter (#4948)

* fix: prevent duplicate dispatch across runners via assignee check + jitter

Root cause: multiple pulse runners evaluating the same issue simultaneously
create duplicate PRs. Process-based dedup (has_worker_for_repo_issue,
is-duplicate) only sees local processes — invisible across machines.

Fix 1: Add is-assigned command to dispatch-dedup-helper.sh that queries
GitHub assignees before dispatch. If another runner already self-assigned,
skip the issue. This is the primary cross-machine dedup guard.

Fix 2: Add 0-30s random startup jitter to pulse-wrapper.sh so concurrent
launchd-triggered pulses don't evaluate issues at the same instant.
Configurable via PULSE_JITTER_MAX (set to 0 to disable).

Fix 3: Update pulse.md dispatch instructions to enforce the assignee
check as a mandatory step alongside existing local process dedup.

Observed: PR #4940 duplicated PR #4938 for issue #4937 because
alex-solovyev's pulse dispatched 2 min after marcusquinn self-assigned,
interpreting the in-progress worker as 'failed'.

* fix: validate PULSE_JITTER_MAX as numeric, use read -ra for assignee parsing

Address Gemini review feedback:
- Validate PULSE_JITTER_MAX is numeric before arithmetic (prevents
  set -e failures from non-integer env var values)
- Use read -ra for comma-separated assignee parsing instead of IFS
  word splitting (more robust against whitespace edge cases)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wp-helper.sh: SSH stdout swallowed — remote WP-CLI output not returned

1 participant