Skip to content

Commit dec7b4d

Browse files
author
Raphaël Droz
committed
If we don't intend to connect through docker, don't even exec() it in the first place. Less syscalls and more apparmor-friendly behavior
1 parent ba1ccab commit dec7b4d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

php/WP_CLI/Runner.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,13 @@ private function generate_ssh_command( $bits, $wp_command ) {
567567
WP_CLI::debug( 'SSH ' . $bit . ': ' . $bits[ $bit ], 'bootstrap' );
568568
}
569569

570-
$is_tty = function_exists( 'posix_isatty' ) && posix_isatty( STDOUT );
571-
$docker_compose_v2_version_cmd = Utils\esc_cmd( Utils\force_env_on_nix_systems( 'docker' ) . ' compose %s', 'version' );
572-
$docker_compose_cmd = ! empty( Process::create( $docker_compose_v2_version_cmd )->run()->stdout )
573-
? 'docker compose'
574-
: 'docker-compose';
570+
$is_tty = function_exists( 'posix_isatty' ) && posix_isatty( STDOUT );
571+
if ( in_array( $bits['scheme'], [ 'docker', 'docker-compose', 'docker-compose-run' ], true ) ) {
572+
$docker_compose_v2_version_cmd = Utils\esc_cmd( Utils\force_env_on_nix_systems( 'docker' ) . ' compose %s', 'version' );
573+
$docker_compose_cmd = ! empty( Process::create( $docker_compose_v2_version_cmd )->run()->stdout )
574+
? 'docker compose'
575+
: 'docker-compose';
576+
}
575577

576578
if ( 'docker' === $bits['scheme'] ) {
577579
$command = 'docker exec %s%s%s sh -c %s';

0 commit comments

Comments
 (0)