-
I have a long running progress-lines-outputting command. In subproc mode I run it like this:
Now I have a xonsh script doing exactly that and in the script, after the command ran I would like to know, what the exit code of So what can I do to get only the exit code in my xonsh script? Thanks for pointers! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The best I could come up with is: $RAISE_SUBPROC_ERROR = True
import subprocess
try:
my_command arg1 arg2
except subprocess.CalledProcessError as e:
# do things in case of failure
# normal continuation This doesn't give the the exit code number but at least a mechanism to see whether exit code was |
Beta Was this translation helpful? Give feedback.
-
You can use ls
# a b
a = ![ls .] # note that output is not captured and streams to stdout
# a b
a.returncode
# 0
a.output # no output captured
# '' |
Beta Was this translation helpful? Give feedback.
You can use
![]
for this. That creates a subproc pipeline that doesn't capture output, but has all of the other attributes of!()
.