Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Handle command exit code when running within winpty #31

Merged
merged 2 commits into from
Apr 27, 2018
Merged

Handle command exit code when running within winpty #31

merged 2 commits into from
Apr 27, 2018

Conversation

ptisserand
Copy link
Contributor

This patch provide support to retrieve command exit code when docker is run under winpty.

@tiangolo
Copy link
Owner

tiangolo commented Nov 1, 2017

Thanks for this!


I'm testing it, but when I run:

docker asdf

and then:

echo $?

I get 0

But if I do the same in Linux:

docker asdf
# docker: 'asdf' is not a docker command.
# See 'docker --help'

echo $?
# 1

I get 1 as the status code. I double checked that I was using your patched version. But still, it seems I'm not getting the status code as expected.

@ptisserand
Copy link
Contributor Author

Thanks for feedback, sorry about this issue with your test case.
I didn't notice it since I was mainly working on running docker within winpty.

I have pushed a fix (349a2d3) which fix this issue on my side.
Please note it's not clear for me why babun bash is using pipestatus (zsh) instead of PIPESTATUS (bash) variable

 { ~ }  » docker adsf                                                                            
docker: 'adsf' is not a docker command.
See 'docker --help'
{ ~ }  » echo $?                                                                              
1
{ ~ }  » docker run --rm -t -i ubuntu /bin/not_here                                            
the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
-- babun-docker: Using winpty
C:\Program Files\Docker\Docker\Resources\bin\docker: Error response from daemon: oci runtime error:
container_linux.go:265: starting container process caused "exec: \"/bin/not_here\": stat /bin/not_he
re: no such file or directory".
{ ~ }  » echo $?                                                                          
127
{ ~ }  » docker pull not_found                                                                  
Using default tag: latest
Error response from daemon: pull access denied for not_found, repository does not exist or may require 'docker login'
{ ~ }  » echo $?                                                                              
1

@ptisserand
Copy link
Contributor Author

Hi @tiangolo , did you check my updated pull request ?

Regards,
Patrice

@tiangolo tiangolo merged commit cc1a8ed into tiangolo:master Apr 27, 2018
@tiangolo
Copy link
Owner

Great! Thanks! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants