Docker does this correctly:
$ docker exec mwcli-mwdd-default_mediawiki_1 bash -c 'exit 5'; echo $? 5
mwcli always returns a 0 exit code:
$ mw dev mw exec -- bash -c 'exit 5'; echo $? 0
$ mw dev mw fresh -- bash -c 'exit 5'; echo $? mwcli-mwdd-default_mediawiki-fresh_1 is up-to-date 0
These commands all make use of the DockerExec function of mwdd
https://gitlab.wikimedia.org/repos/releng/cli/-/blob/3440a732b28fc53b96ad754628c360374ef030aa/internal/mwdd/docker.go#L77
This method has a couple of returns (that also return exit code of 0).
But ultimately at the end of this function once the command that is being run has returned, there is no check of the return status code to pass back to the user.
The code should somehow get this code, and exit with it...
@Addshore suspects this will be done around this area https://gitlab.wikimedia.org/repos/releng/cli/-/blob/3440a732b28fc53b96ad754628c360374ef030aa/internal/mwdd/docker.go#L143-149
Contribution guide...
The code repository is on the Wikimedia gitlab instance https://gitlab.wikimedia.org/repos/releng/cli and is written in GO
Documentation for mwcli is at https://www.mediawiki.org/wiki/Cli (This includes an installation guide, and first setup guide for the dev environment).
If you want to pick up this task please ask @Addshore to be added to the project first. This way you will be able to create a branch on the repository and have CI run.