Prefer /bin/bash and validate SHELL points to bash before using it#81
Open
Prefer /bin/bash and validate SHELL points to bash before using it#81
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix shell binary detection for wp shell command
Use SHELL environment variable before falling back to /bin/bash
Feb 1, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
Use SHELL environment variable before falling back to /bin/bash
Prefer /bin/bash and validate SHELL points to bash before using it
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On systems like NixOS, bash is not located at
/bin/bash. Thewp shellcommand was hardcoded to this path, causing failures despite the shell being available at$SHELL.However, directly using
$SHELLcan breakwp shellfor users whose login shell is not bash (e.g., zsh, fish), since the command uses bash-specific features likehistory -r/-s/-wandread -re.Changes
Shell detection priority in
REPL.php:WP_CLI_CUSTOM_SHELL(explicit override)/bin/bash(preferred when available) ← ensures bash-specific commands workSHELL(only if it points to bash and/bin/bashdoesn't exist) ← new, fixes NixOSbash(final fallback)Added
is_bash_shell()helper: Validates that a shell binary is bash by checking if the basename is exactlybashor starts withbash-(e.g.,bash-5.0), preventing false positives.Test coverage: Added scenario verifying that
SHELLpointing to non-bash shells (e.g.,/bin/sh) is properly ignored and falls back to/bin/bash.This approach fixes the NixOS issue while preventing breakage for users with non-bash login shells.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.