Open ecotechie opened 4 months ago
Pretty sure this would make it easier to have the shell indifferent places and helps us not assume that it's always in /bin/bash
.
I did set define( 'WP_CLI_CUSTOM_SHELL', '/run/current-system/sw/bin/bash' );
in wp-config.php
, tough that could be me #DoingItWrong
WP_CLI_CUSTOM_SHELL
is an environment variable accessed via getenv
. It is not a PHP constant. So you would do this instead:
WP_CLI_CUSTOM_SHELL=/run/current-system/sw/bin/bash wp shell
Forgot to mention I tried that too :blush:
Any thoughts on my idea regarding changing the way that wp shell
checks the shell env? I'd write a pull request, but I am no good at writing tests...
Good question. Maybe @schlessera or @danielbachhuber have some context about why the current default is a hardcoded /bin/bash
and not getenv( 'SHELL' )
. It sounds like a reasonable enhancement at first glance.
I don't recall a specific reason off the top of my head. For a more definitive answer, I'd look at the original pull request(s) to see if there was a discussion around it.
This is when it got added but I found nothing regarding why it was "hard coded" https://github.com/wp-cli/shell-command/commit/bc1322633260db7cf7179f9e1147d4c9ad563658
I'd be happy to test the code, but can't really write tests (on the to learn list).
Bug Report
The shell binary '/bin/bash' is not valid.
The
wp --info
command shows the correctShell
, butwp shell
does not seem to find it. Since it's not in/bin/bash
Describe how other contributors can replicate this bug
get( 'SHELL' );
return something other than/bin/bash
wp shell
Provide a possible solution
Seems that the
wp cli info
command gets the shell binary using:getenv( 'SHELL' )
Where
wp shell
usesgetenv( 'WP_CLI_CUSTOM_SHELL' )
to check for a "custom shell", then assumes/bin/bash
is it isn't set.Why not use
$shell_binary = getenv( 'SHELL' );
instead of$shell_binary = '/bin/bash';