Skip to content

Commit 2071c56

Browse files
Copilotswissspidy
andcommitted
Use SHELL environment variable as fallback before /bin/bash
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent adf5653 commit 2071c56

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

features/shell.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@ Feature: WordPress REPL
6161
"""
6262
And STDERR should be empty
6363
64+
Scenario: Use SHELL environment variable as fallback
65+
Given a WP install
66+
67+
And a session file:
68+
"""
69+
return true;
70+
"""
71+
72+
When I try `SHELL=/bin/bash wp shell --basic < session`
73+
Then STDOUT should contain:
74+
"""
75+
bool(true)
76+
"""
77+
And STDERR should be empty
78+
79+
When I try `SHELL=/nonsense/path wp shell --basic < session`
80+
Then STDOUT should be empty
81+
And STDERR should contain:
82+
"""
83+
Error: The shell binary '/nonsense/path' is not valid.
84+
"""
85+
6486
Scenario: Input starting with dash
6587
Given a WP install
6688
And a session file:

src/WP_CLI/Shell/REPL.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ private static function create_prompt_cmd( $prompt, $history_path ) {
122122
$history_path = escapeshellarg( $history_path );
123123
if ( getenv( 'WP_CLI_CUSTOM_SHELL' ) ) {
124124
$shell_binary = getenv( 'WP_CLI_CUSTOM_SHELL' );
125+
} elseif ( getenv( 'SHELL' ) ) {
126+
$shell_binary = getenv( 'SHELL' );
125127
} else {
126128
$shell_binary = '/bin/bash';
127129
}

0 commit comments

Comments
 (0)