diff --git a/features/shell.feature b/features/shell.feature index d5595506..2974601f 100644 --- a/features/shell.feature +++ b/features/shell.feature @@ -61,6 +61,28 @@ Feature: WordPress REPL """ And STDERR should be empty + Scenario: Use SHELL environment variable as fallback + Given a WP install + + And a session file: + """ + return true; + """ + + When I try `SHELL=/bin/bash wp shell --basic < session` + Then STDOUT should contain: + """ + bool(true) + """ + And STDERR should be empty + + When I try `SHELL=/nonsense/path wp shell --basic < session` + Then STDOUT should contain: + """ + bool(true) + """ + And STDERR should be empty + Scenario: Input starting with dash Given a WP install And a session file: diff --git a/src/WP_CLI/Shell/REPL.php b/src/WP_CLI/Shell/REPL.php index 99b8f1f8..d39bee91 100644 --- a/src/WP_CLI/Shell/REPL.php +++ b/src/WP_CLI/Shell/REPL.php @@ -122,6 +122,8 @@ private static function create_prompt_cmd( $prompt, $history_path ) { $history_path = escapeshellarg( $history_path ); if ( getenv( 'WP_CLI_CUSTOM_SHELL' ) ) { $shell_binary = getenv( 'WP_CLI_CUSTOM_SHELL' ); + } elseif ( getenv( 'SHELL' ) ) { + $shell_binary = getenv( 'SHELL' ); } else { $shell_binary = '/bin/bash'; }